Optaplanner 8.25.0 with WildFly 23.0.2 - wildfly

I have Optaplanner 7.40.0 running in a WildFly 23.0.2 with OpenJDK11.
After upgrading to Optaplanner 8.25.0 I get the error
java.lang.IllegalArgumentException: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD'
Therefore I use another DocumentBuilder as SystemProperty:
- Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
After that the Config can be loaded.
However, I get the following error:
location: package org.drools.ancompiler, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (4:30) : package org.drools.core.rule.accessor does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (6:46) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (7:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (8:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (9:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (10:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (11:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (12:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (13:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (14:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (15:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (16:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (17:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (18:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (19:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (20:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (21:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (22:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (23:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (24:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (25:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (26:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (27:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (28:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (29:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (30:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (31:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (32:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (33:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (34:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (35:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (36:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (37:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (38:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (39:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (40:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (41:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (42:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (43:45) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (44:29) : package org.drools.core.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (45:31) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (46:96) : package org.drools.core.rule.accessor does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (46:172) : package org.drools.core.util.index does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (49:109) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (59:55) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (124:55) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (147:63) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (147:113) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (147:164) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (192:63) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (192:113) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (192:179) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (192:230) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (250:64) : package org.kie.api.definition.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (254:65) : package org.kie.api.definition.rule does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (258:63) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (259:63) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (260:63) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (261:63) : package org.drools.core.common does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (62:70) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (62:113) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (65:70) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (65:113) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (68:57) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (71:70) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (71:113) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (74:57) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (77:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (77:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (80:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (83:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (83:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (86:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (86:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (89:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (92:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (92:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (95:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (98:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (101:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (101:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (104:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (107:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (107:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (110:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (110:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (113:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (116:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (116:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (119:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (127:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (127:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (130:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (133:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (133:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (136:58) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (139:71) : package org.drools.modelcompiler.constraints does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (139:114) : package org.drools.core.reteoo does not exist, org/drools/ancompiler/Compiledcom_mytest_test_task_TaskNetwork31358574213.java (142:58) : package org.drools.core.reteoo does not exist]
at deployment.mytest.war//org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:136)
at deployment.mytest.war//org.kie.memorycompiler.KieMemoryCompiler.compileNoLoad(KieMemoryCompiler.java:104)
at deployment.mytest.war//org.kie.memorycompiler.KieMemoryCompiler.compile(KieMemoryCompiler.java:56)
at deployment.mytest.war//org.kie.memorycompiler.KieMemoryCompiler.compile(KieMemoryCompiler.java:42)
at deployment.mytest.war//org.drools.ancompiler.KieBaseUpdaterANC.inMemoryUpdate(KieBaseUpdaterANC.java:66)
at deployment.mytest.war//org.drools.ancompiler.KieBaseUpdaterANC.run(KieBaseUpdaterANC.java:52)
at deployment.mytest.war//org.drools.ancompiler.KieBaseUpdaterANC.generateAndSetInMemoryANC(KieBaseUpdaterANC.java:99)
at deployment.mytest.war//org.optaplanner.constraint.streams.drools.DroolsConstraintStreamScoreDirectorFactory.buildKieBaseFromModel(DroolsConstraintStreamScoreDirectorFactory.java:97)
at deployment.mytest.war//org.optaplanner.constraint.streams.drools.DroolsConstraintStreamScoreDirectorFactory.buildKieBase(DroolsConstraintStreamScoreDirectorFactory.java:86)
at deployment.mytest.war//org.optaplanner.constraint.streams.drools.DroolsConstraintStreamScoreDirectorFactory.<init>(DroolsConstraintStreamScoreDirectorFactory.java:53)
at deployment.mytest.war//org.optaplanner.constraint.streams.drools.DroolsConstraintStreamScoreDirectorFactoryService.buildScoreDirectorFactory(DroolsConstraintStreamScoreDirectorFactoryService.java:71)
at deployment.mytest.war//org.optaplanner.constraint.streams.drools.DroolsConstraintStreamScoreDirectorFactoryService.lambda$buildScoreDirectorFactory$0(DroolsConstraintStreamScoreDirectorFactoryService.java:50)
at deployment.mytest.war//org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.decideMultipleScoreDirectorFactories(ScoreDirectorFactoryFactory.java:111)
at deployment.mytest.war//org.optaplanner.core.impl.score.director.ScoreDirectorFactoryFactory.buildScoreDirectorFactory(ScoreDirectorFactoryFactory.java:39)
I just pulled Optaplanner into the project as a Maven dependency:
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-core</artifactId>
<version>8.25.0.Final</version>
</dependency>
I tried also optaplanner-core-impl as artifactId.
But then I get this exception:
java.lang.IllegalStateException: Constraint Streams requested via constraintProviderClass (class ...) but the supporting classes were not found on the classpath.
What is the correct way to include OptaPlanner 8.25.0 into WildFly 23.0.2?

Using optaplanner-core is the correct way of including OptaPlanner in your project. optaplanner-core-impl will cause missing dependencies, as you pointed out.
We have never tested OptaPlanner against WildFly - if you can reproduce the problem against the latest version of Wildfly, please file a JIRA with detailed steps to reproduce.
Finally, the original error comes from Drools Alpha Network Compiler. ANC can be disabled in the solver config, and that will likely make the error go away. That said, ANC brings significant performance improvements to the solver, which you will be losing.

Thank you very much,
now it works. I have done the following steps:
swapped DocumentBuilder
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
upgraded Optaplanner to 8.27.0.Final
score engine changed to bavet

Related

Web / Rest Api to get java dependency metadata

I'm looking for some REST Api that provides metada information about java libraries.
My goal is to automate 3rd party dependencies approval process.
I need following metadata about java jars:
Licence
Copyright
Home page url
Official repository url (this part is not required)
I was looking into Sonatype RepoManager Rest but it doesn't return such information
GET /service/rest/v1/components/{id}
{
"id" : "bWF2ZW4tY2VudHJhbDo4ODQ5MWNkMWQxODVkZDEzNjYwYmUwMjE1MjI2NGUwZQ",
"repository" : "maven-central",
"format" : "maven2",
"group" : "org.apache.httpcomponents",
"name" : "httpcomponents-client",
"version" : "4.3.5",
"assets" : [ {
"downloadUrl" : "http://localhost:8081/repository/maven-central/org/apache/httpcomponents/httpcomponents-client/4.3.5/httpcomponents-client-4.3.5.pom",
"path" : "org/apache/httpcomponents/httpcomponents-client/4.3.5/httpcomponents-client-4.3.5.pom",
"id" : "bWF2ZW4tY2VudHJhbDozZjVjYWUwMTc2MDIzM2I2YTFhOGUxOGQxZmFkOGM3Mw",
"repository" : "maven-central",
"format" : "maven2",
"checksum" : {
"sha1" : "95d80a44673358a5dcbcc2f510770b9f93fe5eba",
"md5" : "f4769c4e60799ede664414c26c6c5c9d"
}
}, {
"downloadUrl" : "http://localhost:8081/repository/maven-central/org/apache/httpcomponents/httpcomponents-client/4.3.5/httpcomponents-client-4.3.5.pom.sha1",
"path" : "org/apache/httpcomponents/httpcomponents-client/4.3.5/httpcomponents-client-4.3.5.pom.sha1",
"id" : "bWF2ZW4tY2VudHJhbDpmODk4YjM5MDNjYjk5YzU5ZDU3YjFlYjE0MzM1ZTcwMQ",
"repository" : "maven-central",
"format" : "maven2",
"checksum" : {
"sha1" : "6b98f5cef5d7102f8f45215bdcf48dc843d060af",
"md5" : "f3b3ac640853fcb887621d13029a1747"
}
} ]
}
So, is there an easy way to get dependency metadata?

Data migration is not happening properly to CosmosDB using data Migration tool

I am exporting document using "Sudio 3T" and it generates below JSON.
{ "_id" : { "$oid" : "5aa8bf0077bbfe296c1727de" }, "_t" : "DiscreteProperty", "Name" : "AHRI_bCertified"}
Next I using migration tool import JSON to Azure CosmosDB. Result is, it uploads but not viewing the document because it doesn't _id field.
Note: I am not providing anything in "Id Field" of target screen(CosmosDB).
I followed your steps but did't reproduce your issue.Please refer to my details.
sample .json file:
[
{
"_id" : { "$oid" : "5aa8bf0077bbfe296c1727de" },
"_t" : "DiscreteProperty",
"Name" : "AHRI_bCertified"
}
]
target info:
import result:

Error while looping pymongo object

I have a collection like.
{
"id" : 101,
"name" : "ragav",
"address" : "143 karnadaka",
"products" : [
{
"id" : 2,
"name" : "AA",
"amount" : "150"
},
{
"id" : 4,
"name" : "BB",
"amount" : "15"
},
{
"id" : 6,
"name" : "CC",
"amount" : "210"
},
]
}
I need to find a record in this collection based on product. I running the following query.
Query
db.Response.find(
{"products.id":2},
{"products.id.$":1,"id":1,"name":1,"address":1}
)
In my mongo terminal i got the output. But i accessing through python using pymongo2.8 when i taring to iterate pymongo object getting an error like this.
database error: Executor error: InternalError: ambiguous positional
projection
what is the reason for this error? How it solve??
If a positional operator appears in a projection or update, and there were multiple array matches against the document, MongoDB will issue an error.
so basically the issue is with the $ in the products.id.$
and this is an expected behavior. please refer https://jira.mongodb.org/browse/SERVER-14662 for more info and examples.

How to Store Images into Specified Collections in MongoDB

I know it is possible to save binary files into using MongoDB using the "mongofiles" utility.
Is there any way to store Images into a specified collection, not in db.fs.files?
I want to create an users collection which is using to store user details along with their profile pic like this:
{
"_id" : "USR_1",
"username" : "willsmith123",
"firstname" : "will",
"lastname" : "smith",
"status" : "ACTIVE",
"image" : {
"_id" : ObjectId("558be8062f194d2587000001")
"chunkSize" : 261120,
"uploadDate" : ISODate("2015-06-25T10:20:47.105Z"),
"length" : 25038,
"md5" : "b1d38a0b2ccde6da71fd6ae8fe2f637f",
"filename" : "mylogo.png"
}
}
How can I have a collection like this, which maintain relation between users and their images?
Note:
Database is for data
FileSystem for files
Choice Matters
Use GridFs or else use the below stuff
Instead of saving the embedded document
"image" : {
"chunkSize" : 261120,
"uploadDate" : ISODate("2015-06-25T10:20:47.105Z"),
"length" : 25038,
"md5" : "b1d38a0b2ccde6da71fd6ae8fe2f637f",
"filename" : "mylogo.png"
}
Just save the reference of the image as below
{
"_id" : "USR_1",
"username" : "willsmith123",
"firstname" : "will",
"lastname" : "smith",
"status" : "ACTIVE",
"imageRef" : "unique id (objectID)"
}
Use the imageRef to get or set the image.
When you upload image , writestream create image
id. At the same time , you can't save image id to another
collection.
If you create custom id, it's not safe and problem for
many images.
You can save image info in the document files.metadata

Fix duplicate name situation due to entities created before Orion 0.17.0

Since Orion 0.17.0 attribute type is no longer used as attribute "identification key". However, I have entities created with a pre-0.17.0 version that have attributes with the same name and different types. For example, the following entity, which have "ActivePower" duplicated:
> db.entities.findOne({"_id.type": "Regulator", "_id.id": "OUTSMART.RG_LAS_LLAMAS_01", "_id.servicePath": "/"})
{
"_id" : {
"type" : "Regulator",
"id" : "OUTSMART.RG_LAS_LLAMAS_01",
"servicePath" : "/"
},
"attrs" : [
{
"name" : "TimeInstant",
"value" : "2015-04-27T01:51:36.000000Z",
"type" : "urn:x-ogc:def:trs:IDAS:1.0:ISO8601",
"modDate" : 1430092302
},
{
"name" : "ActivePower",
"value" : "11778",
"type" : "urn:x-ogc:def:phenomenon:Outsmart:1.0:ActivePower",
"modDate" : 1430092302
},
{
"name" : "ReactivePower",
"value" : "8414",
"type" : "urn:x-ogc:def:phenomenon:Outsmart:1.0:ReactivePower",
"modDate" : 1430092302
},
{
"name" : "electricPotential",
"value" : "231",
"type" : "urn:x-ogc:def:phenomenon:IDAS:1.0:electricPotential",
"modDate" : 1430092302
},
{
"name" : "electricCurrent",
"value" : "20890",
"type" : "urn:x-ogc:def:phenomenon:IDAS:1.0:electricCurrent",
"modDate" : 1430092302
},
{
"name" : "Latitud",
"value" : "43.4716987609863",
"type" : "urn:x-ogc:def:phenomenon:IDAS:1.0:latitude",
"modDate" : 1414522843
},
{
"name" : "Longitud",
"value" : "-3.80692005157471",
"type" : "urn:x-ogc:def:phenomenon:IDAS:1.0:longitude",
"modDate" : 1401818472
},
{
"name" : "ActivePower",
"creDate" : 1393420396,
"value" : "11778.2",
"type" : "float",
"modDate" : 1430092302
}
],
"modDate" : 1430092302
}
How can I adapt that entity to work with Orion 0.17.0 and beyond?
The simplest solution is to edit the entity using mongo console, to remove all the "duplicated" attributes with the same name and leave only one. In the example above we have one ActivePower with type urn:x-ogc:def:phenomenon:Outsmart:1.0:ActivePower and other with type float. Let's assume we want to kept the first one.
First of all, stop Orion and take a backup of the database. If something gets wrong while you edit the entity, you could need that backup to go back the initial status and try again.
Next, run mongo console (let's assume that your DB is named "orion") and get the entity to modify using findOne() operation. Let's store it in the doc variable.
# mongo orion
> doc = db.entities.findOne({"_id.type": "Regulator", "_id.id": "OUTSMART.RG_LAS_LLAMAS_01", "_id.servicePath": "/"})
...
Now, identify the position within the attrs array of the attribute to remove, taking into account that the position of the first element in the vector is 0 (and not 1). Looking to the above example, the attribute to remove is the 7-th. Check that printing the attribute:
> doc.attrs[7]
{
"name" : "ActivePower",
"creDate" : 1393420396,
"value" : "11778.2",
"type" : "float",
"modDate" : 1430092302
}
Use splice() function to remove the attribute from doc, using as first parameter the position of the attribute and as second parameter 1. Print the doc value to check that it has been removed:
> doc.attrs.splice(7, 1)
...
> doc
Repeat the above operation as many time as you need to remove all duplicated (in the example case, there is only one duplicated). When you are done, save the new version of the entity in the DB:
> db.entities.save(doc)