Error when querying in IBM Content Navigator - filenet-p8

We are using the IBM Content Navigator 2.0.3 with IBM FileNet P8, Version 5.2. We want to make a query according the Process Engine REST Service Reference. I made an appointment for the columns in a given basket (according here) and I made this query:
[ECM SERVER]/CaseManager/P8BPMREST/p8/bpm/v1/queues/SPLN_Autuacao/workbaskets/Autuacao/columns?cp=CP1
My result was this (showing just 2 columns):
{
...,
"SPLN_itemkey":{
"ordinal":2,
"prompt":"itemkey",
"attributes":"queues\/SPLN_Autuacao\/workbaskets\/Autuacao\/columns\/SPLN_itemkey\/attributes",
"sortable":false,
"type":2,
"name":"SPLN_itemkey"
},
"SPLN_actid":{
"ordinal":3,
"prompt":"actid",
"attributes":"queues\/SPLN_Autuacao\/workbaskets\/Autuacao\/columns\/SPLN_actid\/attributes",
"sortable":false,
"type":1,
"name":"SPLN_actid"
},
...
}
If I make a query with no parameters like
[ECM SERVER]/CaseManager/P8BPMREST/p8/bpm/v1/queues/SPLN_Autuacao/workbaskets/Autuacao/queueelements?cp=CP1
Some results I get are:
{
"lastRecord":null,
"queueElements":[
{
"lockedBy":"",
"stepProcessorId":165458,
"milestones":"queues\/SPLN_Autuacao\/stepelements\/942CF4FC538FDC46A9E3ADBE3CF607C1\/milestones",
"caseTaskId":"{C087B74F-0100-C29D-9C14-EB557CC6F2D6}",
"stepElement":"queues\/SPLN_Autuacao\/stepelements\/942CF4FC538FDC46A9E3ADBE3CF607C1",
"canReassign":true,
"boundUserName":"",
"ETag":"14313.0",
"stepDeadlineStatus":0,
"stepName":"020 Autuacao",
"workObjectNumber":"942CF4FC538FDC46A9E3ADBE3CF607C1",
"caseFolderId":"{C087B74F-0000-C51C-8788-3E63307F980B}",
"queueName":"SPLN_Autuacao",
"lockedById":0,
"columns":{
"F_StepName":"020 Autuacao",
"SPLN_resultout":"COMPLETE: ",
"F_CreateTime":"2015-09-10T13:52:53Z",
"F_Subject":"Fluxo Autuacao",
"SPLN_funcmode":"PR_ELABORACAO:FN_ST_ELABORACAO",
"SPLN_IDDocumento":"1098857",
"SPLN_itemkey":"620006",
"SPLN_itemtype":"SPL",
"SPLN_actid":null,
"SPLN_Natureza":"Mo\u00e7\u00e3o"
}
},
{
"lockedBy":"",
"stepProcessorId":165458,
"milestones":"queues\/SPLN_Autuacao\/stepelements\/9E1DCCF25AEE4A4FA4C61421214B9F40\/milestones",
"caseTaskId":"{008DB74F-0100-C600-9410-D38352275E36}",
"stepElement":"queues\/SPLN_Autuacao\/stepelements\/9E1DCCF25AEE4A4FA4C61421214B9F40",
"canReassign":true,
"boundUserName":"",
"ETag":"14315.0",
"stepDeadlineStatus":0,
"stepName":"020 Autuacao",
"workObjectNumber":"9E1DCCF25AEE4A4FA4C61421214B9F40",
"caseFolderId":"{008DB74F-0000-C516-B965-5D1351219C0E}",
"queueName":"SPLN_Autuacao",
"lockedById":0,
"columns":{
"F_StepName":"020 Autuacao",
"SPLN_resultout":"COMPLETE: ",
"F_CreateTime":"2015-09-10T13:58:38Z",
"F_Subject":"Fluxo Autuacao",
"SPLN_funcmode":"PR_ELABORACAO:FN_ST_ELABORACAO",
"SPLN_IDDocumento":"1098858",
"SPLN_itemkey":"620007",
"SPLN_itemtype":"SPL",
"SPLN_actid":null,
"SPLN_Natureza":"Projeto de lei"
}
},
...
],
...
}
However, if I try to query for a element - let´s say when SPLN_itemkey equals to 620007 - I tried to use a URL such as described here.
[ECM SERVER]/CaseManager/P8BPMREST/p8/bpm/v1/queues/SPLN_Autuacao/workbaskets/Autuacao/queueelements?cp=CP1&filters=[SPLN_itemkey=620006]
I get This error message:
{
"msg":"filenet.pe.rest.VWRESTException",
"UnderlyingDetails":{
"Causes":[
"Invalid filters parameter.\n[FNRPE0450100011E] Invalid filter name",
"Invalid filters parameter.\n[FNRPE0450100011E] Invalid filter name",
"[FNRPE0450100011E] Invalid filter name"
]
},
"stack": "filenet.pe.rest.handlers.QueueElements$FiltersParam.parseFilters(QueueElements.java:458)\r\n\tfilenet.pe.rest.handlers.QueueElements.onGet(QueueElements.java:357)\r\n\tfilenet.pe.rest.P8BPMRESTServlet.doMethod(P8BPMRESTServlet.java:714)\r\n\t",
"UserMessage":{
"UniqueId":"FNRPE0450100011E",
"Severity":"ERROR",
"Text":"[FNRPE0450100011E] Invalid filter name"
}
}
According the message, I am using a invalid filter name. So I tried make filters=[itemkey=620006] instead filters=[SPLN_itemkey=620006]. However I get the same error message.

Actually, the problem was not in the url. It was necessary first create a query in the ECM server to this URL worked.

Related

Updating meta fields in Shopify with GrapQL

I've never used GraphQL before so I am really lacking knowledge on how to go about this. I'm wanting to update product meta fields on Shopify and it appears this is the only way. What I've done so far is really fumbling...
My JSON is:
{
"input": {
"id": "gid://shopify/Product/749521178847",
"metafields": [
{
"id": "gid://shopify/Metafield/2223333",
"value": "Training Grounds"
}
]
}
}
I've minified this to:
{"input":{"id":"gid://shopify/Product/749521178847","metafields":[{"id":"gid://shopify/Metafield/2223333","value":"The Training Grounds"}]}}
And am then using an HTTP request to:
https://MYSTORE.myshopify.com/api/2021-10/graphql.json?query={"input":{"id":"gid://shopify/Product/749521178847","metafields":[{"id":"gid://shopify/Metafield/2223333","value":"The Training Grounds"}]}}
I get the error:
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
I don't know if any of this is correct. If it is, I don't know if ?query= is the right variable to pass it through on.
I recommend you start using Postman, thunder client, or similar to write your graphql queries first, you will learn a lot about how graphql works and the error msgs will be a lot more useful.
To easily connect with Shopify on this stage, go to a store and create a private app, now you can use this for authenticating your API calls.
After that the Shopify graphql works on POST, you can't write your request on GET mode.
It needs to be a POST and you are missing type of operation mutation in this case and what it is.
Postman has https://www.postman.com/lively-moon-541169/workspace/purego-apis/example/16545848-bf0d1589-09b1-4ec6-ba63-a65a56b500eb examples of how to do the calls which can help you.
Also you can check GraphiQL app on shopify to test all the queries before making the programmatic queries
Updating an existing metafield:
mutation {
metafieldsSet(metafields: [
{namespace: "YOURNAMESPACE", ownerId: "gid://shopify/Customer/CUSTOMER_ID", type: "single_line_text_field", key: "YOURKEY", value: "THIS IS NEW VALUE"}
]) {
metafields {
key
value
}
userErrors {
field
message
}
}
}
Creating new metafield:
mutation {
customerUpdate(input: {
id: "gid://shopify/Customer/CUSTOMER_ID",
metafields: [
{key: "newkey", value: "some value", type: "single_line_text_field", namespace: "some namespace"},
]
}) {
userErrors {
field
message
}
}
}

strapi.JS GRAPHQL ERROR "Expected value of type \"StringFilterInput\", found \”anna\”.”,

I'm try GraphQL with strapi.JS and get error in http://localhost:1337/graphql
Very similar work well previously in other website. I'm try before changing other user nothing work.
Here full error:
{
"error": {
"errors": [
{
"message": "Expected value of type \"StringFilterInput\", found \"ann.bystry\".",
"locations": [
{
"line": 2,
"column": 58
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Expected value of type \"StringFilterInput\", found \"ann.bystry\".",
" at isValidValueNode (/Users/ann.bystry/annblogstry/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.js:118:25)",
" at Object.StringValue (/Users/ann.bystry/annblogstry/node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.js:93:14)",
" at Object.enter (/Users/ann.bystry/annblogstry/node_modules/graphql/language/visitor.js:323:29)",
" at Object.enter (/Users/ann.bystry/annblogstry/node_modules/graphql/utilities/TypeInfo.js:370:25)",
" at visit (/Users/ann.bystry/annblogstry/node_modules/graphql/language/visitor.js:243:26)",
" at validate (/Users/ann.bystry/annblogstry/node_modules/graphql/validation/validate.js:69:24)",
" at validate (/Users/ann.bystry/annblogstry/node_modules/apollo-server-koa/node_modules/apollo-server-core/dist/requestPipeline.js:185:39)",
" at processGraphQLRequest (/Users/ann.bystry/annblogstry/node_modules/apollo-server-koa/node_modules/apollo-server-core/dist/requestPipeline.js:90:34)",
" at runMicrotasks (<anonymous>)",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)",
" at async processHTTPRequest (/Users/ann.bystry/annblogstry/node_modules/apollo-server-koa/node_modules/apollo-server-core/dist/runHttpQuery.js:183:30)",
" at async /Users/ann.bystry/annblogstry/node_modules/apollo-server-koa/dist/ApolloServer.js:82:59",
" at async bodyParser (/Users/ann.bystry/annblogstry/node_modules/koa-bodyparser/index.js:95:5)",
" at async cors (/Users/ann.bystry/annblogstry/node_modules/#koa/cors/index.js:98:16)",
" at async returnBodyMiddleware (/Users/ann.bystry/annblogstry/node_modules/#strapi/strapi/lib/services/server/compose-endpoint.js:52:18)",
" at async policiesMiddleware (/Users/ann.bystry/annblogstry/node_modules/#strapi/strapi/lib/services/server/policy.js:28:5)"
]
}
}
}
]
}
}
welcome to Stackoverflow, glad to see you are starting out with Strapi!
If I understand right, you are referring to V4, if you used V3 before, then as #xadm pointed out you likely are providing incorrect input for your GraphQL query filters.
You can always find the definition (the parameters it accepts and the format of them) for StringFilterInput and any other types by clicking on the green "DOCS" label on the right hand side of your GraphQL Playground (Screenshot below):
With this in mind you may want to try querying with the below query (replacing posts with the Collection Type you are searching for)
*also note the " eq: in username filter
query {
posts(filters: { author: { username: { eq: "ann.bystry" } } }) {
data {
id
attributes {
title
# query other fields here
}
}
}
}
Friendly suggestion for future - when you ask a question it is always useful to paste in any relevant code samples and versions of the frameworks/packages you are using :)
Best of luck!

JHipster i18n for entity not being used

I have a a JHipster application and I can see that the UI has all the field labels ok as some sort of defaults. But I also see that the entity specific translations are not being used.
I have a file src/main/webapp/i18n/en/employee.json for example,
{
"myApp": {
"employee": {
"home": {
"title": "Employees",
"createLabel": "Create a new Employee TEST TEST",
"createOrEditLabel": "Create or edit an Employee",
"notFound": "No Employees found"
},
"created": "A new Employee is created with identifier {{ param }}",
"updated": "An Employee is updated with identifier TEST TEST {{ param }}",
"deleted": "An Employee is deleted with identifier {{ param }}",
"delete": {
"question": "Are you sure you want to delete Employee {{ id }}?"
},
"detail": {
"title": "Employee"
},
"Employee": "Employee",
}
}
}
The create label just says "Create a new Employee", not "Create a new Employee TEST TEST".
Also, when I save an entity, I am seeing translation-not-found[A employee is updated with identifier 1]
Adding information suggested to Gaël Marziou.
Does it work when you restart webpack dev server npm start?
I start my server. In a terminal, I do npm start.
Webpack: Finished after 35.767 seconds.
DONE Compiled successfully in 35797ms 12:50:47 PM
No type errors found
Version: typescript 3.4.5
Same error: translation-not-found[A employee is updated with identifier 1].
What are the keys in your HTML templates?
There is a file employee.component.html and it uses keys:
myApp.employee.home.title
myApp.employee.home.createLabel
myApp.employee.home.notFound
global.field.id
myApp.employee.name
entity.action.view
entity.action.edit
entity.action.delete
but in no file so I see the use of myApp.employee.updated - a key that I also added "TEST TEST" to.
Which version of JHipster?
jhipsterVersion "6.7.1"
Found the reason. In EmployeeResource, the updateEmployee was calling a version of createEntityUpdateAlert that just sends a message, not a key.
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, employee.getId().toString()))
.body(result);
Obviously, client side only expected a key and threw an error..
I need to change that to the version that sends a key.
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, employee.getId().toString()))
.body(result);

How to add a json in a nested array of a mongodb document using Spring?

Document stored in mongodb:
{
"CNF_SERVICE_ID":"1",
"SERVICE_CATEGORY":"COMMON_SERVICE",
"SERVICES":[{
"SERVICE_NAME":"Authentication Service",
"VERSIONS":[{
"VERSION_NAME":"AuthenticationServiceV6_3",
"VERSION_NUMBER":"2",
"VERSION_NOTES":"test",
"RELEASE_DATE":"21-02-2020",
"OBSOLETE_DATE":"21-02-2020",
"STATUS":"Y",
"GROUPS":[{
"GROUP_NAME":"TEST GROUP",
"CREATED_DATE":"",
"NODE_NAMES":[
""
],
"CUSTOMERS":[{
"CUSTOMER_CONFIG_ID":"4",
"ACTIVATION_DATE":"21-02-2020",
"DEACTIVATION_DATE":"21-02-2020",
"STATUS":"Y"
}]
}]
}]
}
]
}
Now, I need to add another customer json to the array "CUSTOMERS" inside "GROUPS" in the same document above. The customer json would be like this:
{
"CUSTOMER_CONFIG_ID":"10",
"ACTIVATION_DATE":"16-03-2020",
"DEACTIVATION_DATE":"16-03-2021",
"STATUS":"Y"
}
I tried this:
Update update = new Update().push("SERVICES.$.VERSIONS.GROUPS.CUSTOMERS",customerdto);
mongoOperations.update(query, update, Myclass.class, "mycollection");
But, I am getting the exception: org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 28 (PathNotViable): 'Cannot create field 'GROUPS' in element
[ EDIT ADD ]
I was able to update it using the filtered positional operator. Below is the query I used:
update(
{ "SERVICE_CATEGORY":"COMMON_SERVICE", "SERVICES.SERVICE_NAME":"Authentication Service", "SERVICES.VERSIONS.VERSION_NAME":"AuthenticationServiceV6_3"},
{ $push:{"SERVICES.$[].VERSIONS.$[].GROUPS.$[].CUSTOMERS": { "CUSTOMER_CONFIG_ID":"6", "ACTIVATION_DATE":"31-03-2020", "STATUS":"Y" } } }
);
Actually, this query updated all the fields irrespective of the filter conditions. So. I tried this but I am facing syntax exception. Please help.
update(
{"SERVICE_CATEGORY":"COMMON_SERVICE"},
{"SERVICES.SERVICE_NAME":"Authentication Service"},
{"SERVICES.VERSIONS.VERSION_NAME":"AuthenticationServiceV6_3"}
{
$push:{"SERVICES.$[service].VERSIONS.$[version].GROUPS.$[group].CUSTOMERS":{
"CUSTOMER_CONFIG_ID":"6",
"ACTIVATION_DATE":"31-03-2020",
"STATUS":"Y"
}
}
},
{
multi: true,
arrayFilters: [ { $and:[{ "version.VERSION_NAME": "AuthenticationServiceV6_3"},{"service.SERVICE_NAME":"Authentication Service"},{"group.GROUP_NAME":"TEST GROUP"}]} ]
}
);
Update: April 1,2020
The code I tried:
validationquery.addCriteria(Criteria.where("SERVICE_CATEGORY").is(servicedto.getService_category()).and("SERVICES.SERVICE_NAME").is(servicedetail.getService_name()).and("SERVICES.VERSIONS.VERSION_NAME").is(version.getVersion_name()));
Update update=new Update().push("SERVICES.$[s].VERSIONS.$[v].GROUPS.$[].CUSTOMERS", customer).filterArray(Criteria.where("SERVICE_CATEGORY").is(servicedto.getService_category()).and("s.SERVICE_NAME").is(servicedetail.getService_name()).and("v.VERSION_NAME").is(version.getVersion_name()));
mongoOperations.updateMulti(validationquery, update, ServiceRegistrationDTO.class, collection, key,env);
The below exception is thrown:
ERROR com.sample.amt.mongoTemplate.MongoOperations - Exception in count(query, collectionName,key,env) :: org.springframework.dao.DataIntegrityViolationException: Error parsing array filter :: caused by :: Expected a single top-level field name, found 'SERVICE_CATEGORY' and 's'; nested exception is com.mongodb.MongoWriteException: Error parsing array filter :: caused by :: Expected a single top-level field name, found 'SERVICE_CATEGORY' and 's'
This update query adds the JSON to the nested array, "SERVICES.VERSIONS.GROUPS.CUSTOMERS", based upon the specified filter conditions. Note that your filter conditions direct the update operation to the specific array (of the nested arrays).
// JSON document to be added to the CUSTOMERS array
new_cust = {
"CUSTOMER_CONFIG_ID": "6",
"ACTIVATION_DATE": "31-03-2020",
"STATUS": "Y"
}
db.collection.update(
{
"SERVICE_CATEGORY": "COMMON_SERVICE",
"SERVICES.SERVICE_NAME": "Authentication Service",
"SERVICES.VERSIONS.VERSION_NAME": "AuthenticationServiceV6_3"
},
{
$push: { "SERVICES.$[s].VERSIONS.$[v].GROUPS.$[g].CUSTOMERS": new_cust }
},
{
multi: true,
arrayFilters: [
{ "s.SERVICE_NAME": "Authentication Service" },
{ "v.VERSION_NAME": "AuthenticationServiceV6_3" },
{ "g.GROUP_NAME": "TEST GROUP" }
]
}
);
Few things to note when updating documents with nested arrays of more than one level nesting.
Use the all positional operator $[] and the filtered positional
operator $[<identifier>], and not the $ positional operator.
With filtered positional operator specify the array filter conditions
using the arrayFilters parameter. Note that this will direct your update to target the specific nested array.
For the filtered positional operator $[<identifier>], the
identifier must begin with a lowercase letter and contain only
alphanumeric characters.
References:
Array Update
Operators
db.collection.update() with arrayFilters
Thanks to #prasad_ for providing the query. I was able to eventually convert the query successfully to code with Spring data MongoTemplate's updateMulti method. I have posted the code below:
Query validationquery = new Query();
validationquery.addCriteria(Criteria.where("SERVICE_CATEGORY").is(servicedto.getService_category()).and("SERVICES.SERVICE_NAME").is(servicedetail.getService_name()).and("SERVICES.VERSIONS.VERSION_NAME").is(version.getVersion_name()));
Update update=new Update().push("SERVICES.$[s].VERSIONS.$[v].GROUPS.$[].CUSTOMERS", customer).filterArray(Criteria.where("s.SERVICE_NAME").is(servicedetail.getService_name())).filterArray(Criteria.where("v.VERSION_NAME").is(version.getVersion_name()));
mongoOperations.updateMulti(validationquery, update, ServiceRegistrationDTO.class, collection, key,env);
mongoTemplateobj.updateMulti(validationquery, update, ServiceRegistrationDTO.class, collection, key,env);

What is the best way to validate data in mongo?

What's the best way to validate data being inserted or updated into MongoDB? Is it to write some sort of server executed Javascript code that does the validation?
Starting from MongoDB 3.2 they added document validation (slides).
You can specify validation rules for each collection, using validator option using almost all mongo query operators (except $geoNear, $near, $nearSphere, $text, and $where).
To create a new collection with a validator, use:
db.createCollection("your_coll", {
validator: { `your validation query` }
})
To add a validator to the existing collection, you can add the validator:
db.createCollection("your_coll", {
validator: { `your validation query` }
})
Validation work only on insert/update, so when you create a validator on your old collection, the previous data will not be validated (you can write application level validation for a previous data). You can also specify validationLevel and validationAction to tell what will happen if the document will not pass the validation.
If you try to insert/update the document with something that fails the validation, (and have not specified any strange validationLevel/action) then you will get an error on writeResult (sadly enough the error does not tell you what failed and you get only default validation failed):
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 121,
"errmsg" : "Document failed validation"
}
})
MongoDB doesn't have constraints or triggers so the application has to validate the data.
You can also write Javascript scripts that check once a day or more if there is invalid data. You can use this to check the quality of the business logic of your application.
I think it would be normal for your app to handle this kind of thing. If the data is invalid in some way, don't let it get added to the datastore until the user has corrected whatever error you have detected.
Starting in 2.4, MongoDB enables basic BSON object validation for mongod and mongorestore when writing to MongoDB data files. This prevents any client from inserting invalid or malformed BSON into a MongoDB database.
source: http://docs.mongodb.org/manual/release-notes/2.4/
Starting MongoDB 3.6 you can also use JSON Schema to express validation rules. These checks will happen on the database side on insert/update.
Here is an example from the docs:
validator = {
$jsonSchema: {
bsonType: "object",
required: [ "name", "year", "major", "address" ],
properties: {
name: {
bsonType: "string",
description: "must be a string and is required"
},
year: {
bsonType: "int",
minimum: 2017,
maximum: 3017,
description: "must be an integer in [ 2017, 3017 ] and is required"
},
major: {
enum: [ "Math", "English", "Computer Science", "History", null ],
description: "can only be one of the enum values and is required"
},
gpa: {
bsonType: [ "double" ],
description: "must be a double if the field exists"
},
address: {
bsonType: "object",
required: [ "city" ],
properties: {
street: {
bsonType: "string",
description: "must be a string if the field exists"
},
city: {
bsonType: "string",
description: "must be a string and is required"
}
}
}
}
}
}
db.runCommand( {
collMod: "collectionName",
validator: validator
} )
I've just started using MongoDB and PHP together, inside a Zend Framework based application.
I have created 1 object for each MongoDB collection (e.g. User.php maps to the user collection). Each object knows what collection it maps to, and what fields are required. It also knows which filters (Zend_Filter_Input) and validators (Zend_Validate) should be applied to each field. Before doing a MongoDB insert() or save(), I run $object->isValid(), which executes all the validators. If they all pass isValid() will return true, and I proceed to run the insert() or save(), otherwise I display the errors.

Resources