Rewrite JSON structure using cypress - cypress

[
{
"routineCode": "StudentMapping",
"routineId": "NIL",
"routineClass": "NIL",
"routineUpdate": "NIL",
"routineMap": "Create-Role-Grade"
},
{
"routineCode": "createRole",
"routineId": "791",
"routineClass": "POCOD1",
"routineUpdate": "Yes",
"routineMap": "Create-Role"
},
{
"routineCode": "createGrade",
"routineId": "3094",
"routineClass": "DWR145",
"routineUpdate": "Yes",
"routineMap": "Create-Grade"
},
{
"routineCode": "StudentMapping",
"routineId": "NIL",
"routineClass": "NIL",
"routineUpdate": "NIL",
"routineMap": "Edit-Role-Grade"
},
{
"routineCode": "EditRole",
"routineId": "791",
"routineClass": "POCOD5",
"routineUpdate": "Yes",
"routineMap": "Edit-Role"
},
{
"routineCode": "EditGrade",
"routineId": "3094",
"routineClass": "DWR298",
"routineUpdate": "Yes",
"routineMap": "Edit-Grade"
},
{
"routineCode": "StudentMapping",
"routineId": "NIL",
"routineClass": "NIL",
"routineUpdate": "NIL",
"routineMap": "Delete-Role-Grade"
},
{
"routineCode": "DeleteRole",
"routineId": "791",
"routineClass": "POCOD5",
"routineUpdate": "Yes",
"routineMap": "Delete-Role"
},
{
"routineCode": "DeleteGrade",
"routineId": "3094",
"routineClass": "DWR298",
"routineUpdate": "Yes",
"routineMap": "Delete-Grade"
}
]
The JSON file have the above data. The JSON object from JSON file have been stored like this in Cypress:
const jsonObjectRoute = require('../../fixtures/routeMap.json');
Now, this json object need to be reframed as like below using Cypress. Then, need to open 1st for loop to print the routineCode and routineMap and 2nd for loop to print the items.
Could anyone help on this?
[
{
"routineCode": "StudentMapping",
"routineMap": "Create-Role-Grade"
"items": [
{
"routineCode": "createRole",
"routineId": "791",
"routineClass": "POCOD1",
"routineUpdate": "Yes",
"routineMap": "Create-Role"
},
{
"routineCode": "createGrade",
"routineId": "3094",
"routineClass": "DWR145",
"routineUpdate": "Yes",
"routineMap": "Create-Grade"
},
]
},
{
"routineCode": "StudentMapping",
"routineMap": "Edit-Role-Grade",
"items": [
{
"routineCode": "EditRole",
"routineId": "791",
"routineClass": "POCOD5",
"routineUpdate": "Yes",
"routineMap": "Edit-Role"
},
{
"routineCode": "EditGrade",
"routineId": "3094",
"routineClass": "DWR298",
"routineUpdate": "Yes",
"routineMap": "Edit-Grade"
},
]
},
{
"routineCode": "StudentMapping",
"routineMap": "Delete-Role-Grade"
"items": [
{
"routineCode": "DeleteRole",
"routineId": "791",
"routineClass": "POCOD5",
"routineUpdate": "Yes",
"routineMap": "Delete-Role"
},
{
"routineCode": "DeleteGrade",
"routineId": "3094",
"routineClass": "DWR298",
"routineUpdate": "Yes",
"routineMap": "Delete-Grade"
},
]
}
]

Related

Laravel Eloquent Nested Eager Load Apply Order By

Given this data:
{
"current_page": 1,
"data": [
{
"id": 1,
"delivery_id": 1,
"deliveries_sub": {
"first_delivery_date": "08/31/2022",
"delivery" {
"day": "Monday",
"location": {
"direction": "North"
}
}
}
},
{
"id": 2,
"delivery_id": 2,
"deliveries_sub": {
"first_delivery_date": "09/28/2022",
"delivery" {
"day": "Friday",
"location": {
"direction": "South"
}
}
}
},
{
"id": 3,
"delivery_id": 2,
"deliveries_sub": {
"first_delivery_date": "08/31/2022",
"delivery" {
"day": "Wednesday",
"location": {
"direction": "Northeast"
}
}
}
},
{
"id": 4,
"delivery_id": 3,
"deliveries_sub": {
"first_delivery_date": "09/02/2022",
"delivery" {
"day": "Tueday",
"location": {
"direction": "North"
}
}
}
}
],
"first_page_url": "http://localhost/mypage/list?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://localhost/mypage/list?page=1",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://localhost/mypage/list?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"next_page_url": null,
"path": "http://localhost/mypage/list",
"per_page": 10,
"prev_page_url": null,
"to": 4,
"total": 4
}
I would like to sort it by the first_delivery_date. I have fetched this one using:
DeliveryDays::with('deliverySub.delivery.location')
->orderBy('deliverySub.first_delivery_date')
->paginate(10);
It seems that the orderBy clause is not working. I've also tried this approach:
DeliveryDays::with(['deliverySub' => function ($query) {
$query->orderBy('first_delivery_date');
}, 'deliverySub.delivery.location'])
->paginate(10);
But it also doesn't work. My desired result would be the sorted first_delivery_date data:
{
"current_page": 1,
"data": [
{
"id": 1,
"delivery_id": 1,
"deliveries_sub": {
"first_delivery_date": "08/31/2022",
"delivery" {
"day": "Monday",
"location": {
"direction": "North"
}
}
}
},
{
"id": 3,
"delivery_id": 2,
"deliveries_sub": {
"first_delivery_date": "08/31/2022",
"delivery" {
"day": "Wednesday",
"location": {
"direction": "Northeast"
}
}
}
},
{
"id": 4,
"delivery_id": 3,
"deliveries_sub": {
"first_delivery_date": "09/02/2022",
"delivery" {
"day": "Tueday",
"location": {
"direction": "North"
}
}
}
},
{
"id": 2,
"delivery_id": 2,
"deliveries_sub": {
"first_delivery_date": "09/28/2022",
"delivery" {
"day": "Friday",
"location": {
"direction": "South"
}
}
}
}
],
"first_page_url": "http://localhost/mypage/list?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://localhost/mypage/list?page=1",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://localhost/mypage/list?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"next_page_url": null,
"path": "http://localhost/mypage/list",
"per_page": 10,
"prev_page_url": null,
"to": 4,
"total": 4
}
What would be the best approach for sorting the results? Is it within the eager load or after fetching the results? Thanks.
Try this
DeliveryDays::with(['deliverySub' => function($query){
$query->orderBy('first_delivery_date');
}, 'deliverySub.delivery.location'])->paginate(10);

Laravel 5.5 echo unable to listen to channel

I am currently using laravel-echo along with with pusher to set up my channel and broadcast however there seems to be some issues creating the listener onto the channel.
There should be a message on the pusher dashboard indicating that the channel is being listened to when the page is entered but nothing is being displayed
Initializing Echo Listener
$(document).ready(function() {
try{
window.Echo.channel('chat-room')
.listen('scannedQR', (e) => {
console.log("event has been triggered");
alert('event has been triggered');
});
alert('success');
}
catch(e){
console.log(e);
alert(e);
}
}
Bootstrap
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Lover = "LOVER!";
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'key',
// cluster: 'mt1',
cluster:'ap1',
encrypted: true
});
Echo Object -> console.log(JSON.safeStringify(window.Echo));
{
"options": {
"broadcaster": "pusher",
"key": key,
"cluster": cluster,
"encrypted": true
},
"connector": {
"_defaultOptions": {
"auth": {
"headers": {
"X-CSRF-TOKEN": "oIywz9kkxhVbl109qOqXMy0NVrUCR5AZlYR5apPc"
}
},
"authEndpoint": "/broadcasting/auth",
"userAuthentication": {
"endpoint": "/broadcasting/user-auth",
"headers": {
"X-CSRF-TOKEN": "oIywz9kkxhVbl109qOqXMy0NVrUCR5AZlYR5apPc"
}
},
"broadcaster": "pusher",
"csrfToken": null,
"host": null,
"key": key,
"namespace": "App.Events",
"cluster": "ap1",
"encrypted": true
},
"pusher": {
"key": key,
"config": {
"activityTimeout": 120000,
"cluster": "ap1",
"httpPath": "/pusher",
"httpPort": 80,
"httpsPort": 443,
"pongTimeout": 30000,
"statsHost": "stats.pusher.com",
"unavailableTimeout": 10000,
"wsPath": "",
"wsPort": 80,
"wssPort": 443,
"enableStats": false,
"httpHost": "sockjs-ap1.pusher.com",
"useTLS": true,
"wsHost": "ws-ap1.pusher.com"
},
"channels": {
"channels": {}
},
"global_emitter": {
"callbacks": {
"_callbacks": {}
},
"global_callbacks": []
},
"sessionID": 299457458,
"timeline": {
"key": key,
"session": 299457458,
"events": [
{
"instances": 1,
"timestamp": 1660358957487
},
{
"state": "connecting",
"timestamp": 1660358957538
},
{
"cached": true,
"transport": "xhr_streaming",
"latency": 410,
"timestamp": 1660358957539
},
{
"cid": 1,
"transport": "xhr_streamings",
"timestamp": 1660358957539
},
{
"cid": 1,
"state": "initialized",
"timestamp": 1660358957539
},
{
"cid": 1,
"state": "connecting",
"timestamp": 1660358957541
},
{
"cid": 1,
"state": "open",
"timestamp": 1660358957974
},
{
"state": "connected",
"params": {
"socket_id": "17356.8786996"
},
"timestamp": 1660358957976
}
],
"options": {
"cluster": cluster,
"features": [
"ws"
],
"params": {},
"limit": 50,
"level": 6,
"version": "7.3.0"
},
"sent": 0,
"uniqueID": 1
},
"connection": {
"callbacks": {
"_callbacks": {
"_connected": [
{},
{}
],
"_message": [
{},
{}
],
"_connecting": [
{},
{}
],
"_disconnected": [
{},
{}
],
"_error": [
{}
]
}
},
"global_callbacks": [],
"state": "connected",
"connection": {
"callbacks": {
"_callbacks": {
"_tls_only": [
{}
],
"_refused": [
{}
],
"_backoff": [
{}
],
"_retry": [
{}
],
"_message": [
{}
],
"_ping": [
{}
],
"_activity": [
{}
],
"_error": [
{}
],
"_closed": [
{}
]
}
},
"global_callbacks": [],
"id": "17356.8786996",
"transport": {
"callbacks": {
"_callbacks": {
"_error": [
{}
],
"_closed": [
{},
{}
],
"_message": [
{}
],
"_activity": [
{}
]
}
},
"global_callbacks": [],
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
},
"name": "xhr_streaming",
"priority": 1,
"key": key,
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
},
"state": "open",
"id": 1,
"socket": {
"hooks": {},
"session": "428/90n18c0a",
"location": {
"base": base,
"queryString": "?protocol=7&client=js&version=7.3.0"
},
"readyState": 1,
"stream": {
"callbacks": {
"_callbacks": {
"_chunk": [
{}
],
"_finished": [
{}
],
"_buffer_too_long": [
{}
]
}
},
"global_callbacks": [],
"hooks": {},
"method": "POST",
"url": url,
"position": 2188,
"xhr": {}
}
}
}
},
"key": key,
"options": {
"activityTimeout": 120000,
"pongTimeout": 30000,
"unavailableTimeout": 10000,
"useTLS": true
},
"usingTLS": true,
"errorCallbacks": {},
"connectionCallbacks": {},
"handshakeCallbacks": {},
"strategy": {
"strategy": {
"strategy": {
"trueBranch": {
"strategies": [
{
"strategies": [
{
"name": "ws",
"priority": 3,
"transport": {
"manager": {
"options": {
"lives": 2,
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"livesLeft": 2
},
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": false
}
},
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "ws-ap1.pusher.com:80",
"hostTLS": "ws-ap1.pusher.com:443",
"httpPath": ""
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
{
"strategy": {
"trueBranch": {
"strategies": [
{
"trueBranch": {
"strategies": [
{
"strategies": [
{
"trueBranch": {
"name": "xhr_streaming",
"priority": 1,
"transport": {
"manager": {
"options": {
"lives": 2,
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"livesLeft": 2
},
"transport": {},
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
},
"falseBranch": {
"name": "xdr_streaming",
"priority": 1,
"transport": {
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
}
},
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
{
"strategy": {
"strategies": [
{
"trueBranch": {
"name": "xhr_polling",
"priority": 1,
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
}
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
},
"falseBranch": {
"name": "xdr_polling",
"priority": 1,
"transport": {
"hooks": {
"urls": {},
"handlesActivityChecks": false,
"supportsPing": true
}
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
"options": {
"delay": 4000
}
}
]
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
},
"falseBranch": {
"strategies": [
{
"name": "sockjs",
"priority": 1,
"transport": {
"hooks": {
"file": "sockjs",
"urls": {},
"handlesActivityChecks": true,
"supportsPing": false
}
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "sockjs-ap1.pusher.com:80",
"hostTLS": "sockjs-ap1.pusher.com:443",
"httpPath": "/pusher"
}
}
],
"loop": true,
"failFast": false,
"timeout": 15000,
"timeoutLimit": 60000
}
},
"options": {
"delay": 2000
}
}
]
}
}
},
"transports": {
"wss": {
"name": "wss",
"priority": 3,
"transport": {
"minPingDelay": 10000,
"maxPingDelay": 120000
},
"options": {
"key": key,
"useTLS": true,
"hostNonTLS": "ws-ap1.pusher.com:80",
"hostTLS": "ws-ap1.pusher.com:443",
"httpPath": ""
}
}
},
"ttl": 1800000,
"usingTLS": true
},
"runner": null,
"unavailableTimer": {
"timer": null
},
"activityTimeout": 120000,
"activityTimer": {
"timer": 5
},
"socket_id": "17356.8786996"
},
"user": {
"callbacks": {
"_callbacks": {}
},
"global_callbacks": [],
"signin_requested": false,
"user_data": null,
"serverToUserChannel": null
}
},
"channels": {}
}
}
Pusher Dashboard doesn't show that channel is being listened to
EDIT
It currently shows on the pusher dashboard that the channel is being listened to but laravel-echo doesn't catch the event on the front end

Using loadable, common files are bundled into a common bundle

I am using loadable for code splitting. The problem is all my files which are being used in more than one file are bundle into my initial bundle which is making it too large. Instead I want them to be included in my particular route bundle which is opened. How can I solve this?
I want my files to be included in route bundle only. I don't want any common bundle.
This is my webpack config
{
"cache": true,
"context": "/src/client",
"entry": {
"desktop": "./app.desktop.jsx",
"mobile": "./app.mobile.jsx"
},
"output": {
"path": "repo_name/dist/js",
"pathinfo": false,
"publicPath": "https://{url}/js/",
"chunkFilename": "[contenthash].[name].js",
"filename": "[name].bundle.[contenthash].js"
},
"resolve": {
"alias": {},
"symlinks": true,
"plugins": [{
"source": "module",
"nmPath": "node_modules",
"originDir": "repo_name/node_modules/electrode-archetype-react-app-dev",
"target": "resolve"
}],
"modules": [
"repo_name/src",
"repo_name",
"node_modules"
],
"extensions": [
".js",
".jsx",
".json"
]
},
"resolveLoader": {
"symlinks": true,
"modules": [
"repo_name/lib",
"repo_name"
],
"plugins": [{
"source": "module",
"nmPath": "node_modules",
"originDir": "repo_name/node_modules/electrode-archetype-react-app-dev",
"target": "resolve"
}]
},
"module": {
"rules": [{
"test": {},
"use": [{
"loader": "repo_name/node_modules/babel-loader/lib/index.js",
"options": {
"cacheDirectory": "repo_name/.etmp/babel-loader"
}
}]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/mini-css-extract-plugin/dist/loader.js",
"options": {
"hmr": false,
"reload": false,
"publicPath": "/js/"
}
},
{
"loader": "repo_name/node_modules/css-loader/index.js",
"options": {
"context": "repo_name/src",
"modules": true,
"localIdentName": "[hash:base64:5]"
}
},
{
"loader": "repo_name/node_modules/postcss-loader/src/index.js",
"options": {
"ident": "postcss"
}
}
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/mini-css-extract-plugin/dist/loader.js",
"options": {
"hmr": false,
"reload": false,
"publicPath": ""
}
},
{
"loader": "repo_name/node_modules/css-loader/index.js",
"options": {
"context": "repo_name/src",
"modules": true,
"localIdentName": "[hash:base64:5]"
}
},
{
"loader": "repo_name/node_modules/postcss-loader/src/index.js",
"options": {
"ident": "postcss"
}
},
{
"loader": "repo_name/node_modules/sass-loader/lib/loader.js"
}
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/mini-css-extract-plugin/dist/loader.js",
"options": {
"hmr": false,
"reload": false,
"publicPath": ""
}
},
{
"loader": "repo_name/node_modules/css-loader/index.js",
"options": {
"context": "repo_name/src",
"modules": true,
"localIdentName": "[hash:base64:5]"
}
},
{
"loader": "repo_name/node_modules/postcss-loader/src/index.js",
"options": {
"ident": "postcss"
}
},
{
"loader": "repo_name/node_modules/stylus-relative-loader/index.js"
}
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/url-loader/index.js",
"options": {
"limit": 1000,
"mimetype": "application/font-woff"
}
},
"repo_name/node_modules/isomorphic-loader/index.js"
]
},
{
"test": {},
"use": [
"repo_name/node_modules/file-loader/dist/cjs.js",
"repo_name/node_modules/isomorphic-loader/index.js"
]
},
{
"test": {},
"use": [{
"loader": "repo_name/node_modules/electrode-cdn-file-loader/index.js",
"options": {
"limit": 10000
}
},
"repo_name/node_modules/isomorphic-loader/index.js"
]
}
]
},
"plugins": [{
"options": {
"filename": "[name].style.[contenthash].css",
"chunkFilename": "[name].style.[contenthash].css"
},
"__name": "MiniCssExtractPlugin"
},
{
"pluginDescriptor": {
"name": "OptimizeCssAssetsWebpackPlugin"
},
"options": {
"assetProcessors": [{
"phase": "compilation.optimize-chunk-assets",
"regExp": {}
}],
"assetNameRegExp": {},
"cssProcessorOptions": {
"zindex": false
},
"cssProcessorPluginOptions": {}
},
"phaseAssetProcessors": {
"compilation.optimize-chunk-assets": [{
"phase": "compilation.optimize-chunk-assets",
"regExp": {}
}],
"compilation.optimize-assets": [],
"emit": []
},
"deleteAssetsMap": {},
"__name": "OptimizeCssAssetsWebpackPlugin"
},
{
"options": {
"minimize": true,
"options": {
"context": "repo_name/src"
},
"test": {}
},
"__name": "LoaderOptionsPlugin"
},
{
"opts": {
"filename": "../server/stats.json",
"fields": [
"assetsByChunkName",
"assets",
"entrypoints",
"chunks"
]
},
"__name": "StatsWriterPlugin"
},
{
"config": {
"valid": false
},
"options": {
"assetsFile": "../isomorphic-assets.json",
"configFile": "repo_name/.isomorphic-loader-config.json",
"webpackDev": {
"url": "http://localhost:2992",
"addUrl": false
}
},
"__name": "IsomorphicLoaderPlugin"
},
{
"opts": {
"filename": "../server/loadable-stats.json",
"outputAsset": true
},
"compiler": null,
"__name": "LoadablePlugin"
},
{
"resourceRegExp": {},
"newContentRegExp": {},
"__name": "ContextReplacementPlugin"
},
{
"sourceMapFilename": "../map/[file].map",
"sourceMappingURLComment": "\n//# sourceMappingURL=/map/[url]",
"moduleFilenameTemplate": "webpack://[namespace]/[resourcePath]",
"fallbackModuleFilenameTemplate": "webpack://[namespace]/[resourcePath]?[hash]",
"namespace": "",
"options": {
"filename": "../map/[file].map",
"append": "\n//# sourceMappingURL=/map/[url]"
},
"__name": "SourceMapDevToolPlugin"
},
{
"isWatch": true,
"__name": "FailPlugin"
},
{
"__name": "DonePlugin"
},
{
"opts": {
"analyzerMode": "server",
"analyzerHost": "127.0.0.1",
"analyzerPort": 8888,
"reportFilename": "report.html",
"defaultSizes": "parsed",
"openAnalyzer": true,
"generateStatsFile": false,
"statsFilename": "stats.json",
"statsOptions": null,
"excludeAssets": null,
"logLevel": "info",
"startAnalyzer": true
},
"server": null,
"logger": {
"activeLevels": {}
}
},
{
"options": {},
"timeEventData": {},
"smpPluginAdded": true
}
],
"mode": "production",
"optimization": {
"splitChunks": {
"cacheGroups": {
"node_vendors": {
"name": "node_vendor",
"test": {},
"chunks": "initial",
"priority": 1
},
"sentry": {
"name": "sentry",
"test": {},
"chunks": "all",
"priority": 10
}
}
}
}
}

Parsing array of objects using Logstash

I have JMS message payload containing array of customer objects which needs to indexed into elastic search.
JMS Payload
{
"file": {
"header": {
"id": "13",
"name": "ElasticCustomer",
"description": "ElasticCustomer",
"version": "Version 1",
"exportID": "ElasticCustomer",
"exportInstance": "20200918043921264",
"extractionMode": "FULL",
"extractionDate": "2020-09-18T05:37:32"
},
"body": {
"records": [
{
"customerId": "NVS1200063862",
"URI": "https://data.novartis.net/r1/commercial/customer_management/customer_mdm/v1/customer/HCO/NVS1200063862",
"customerCountry": "200024",
"type": {
"linked_record": {
"code": "200027",
"description": "Health Care Organization",
"shortDescription": "HCO",
"remoteKeys": {
"linked_records": []
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200027",
"foreignKey": "200027",
"linkedTable": "/root/ReferenceData"
}
}
},
"veevaRecordType": {
"recordTypeId": "012A0000000zC10IAE",
"recordTypeValue": "PH_CORE-Clinics"
},
"status": {
"linked_record": {
"code": "200036",
"description": "Active",
"shortDescription": null,
"remoteKeys": {
"linked_records": [
{
"system": "200073",
"systemKey": "STA.3",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6099",
"linkedTable": "/root/RemoteKeys"
}
},
{
"system": "200072",
"systemKey": "Active",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6351",
"linkedTable": "/root/RemoteKeys"
}
},
{
"system": "200071",
"systemKey": "Active",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6353",
"linkedTable": "/root/RemoteKeys"
}
}
]
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200036",
"foreignKey": "200036",
"linkedTable": "/root/ReferenceData"
}
}
},
"statusReason": {
"linked_record": {}
},
"hco": "HCO1200016052",
"hcp": null,
"healthCareOrganisation": {
"linked_records": []
},
"healthCareProfessional": {
"linked_records": []
},
"communication": {
"linked_records": [
{
"communicationId": 2739472,
"customerId": "NVS1200063862",
"communicationType": {
"linked_record": {
"code": "200146",
"description": "Communication Channel",
"shortDescription": null,
"remoteKeys": {
"linked_records": []
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200146",
"foreignKey": "200146",
"linkedTable": "/root/ReferenceData"
}
}
},
"type": "212126",
"value": "519 2046052",
"status": {
"linked_record": {
"code": "200084",
"description": "Active",
"shortDescription": null,
"remoteKeys": {
"linked_records": []
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200084",
"foreignKey": "200084",
"linkedTable": "/root/ReferenceData"
}
}
},
"isPrimary": false,
"technicalData": {
"lastUser": "sys_apimdmprod",
"creationTime": "2020-08-07T08:01:30",
"lastTime": "2020-08-07T08:01:30",
"primaryKey": "2739472",
"linkedTable": "/root/Communication"
}
}
]
},
"remoteKeys": {
"linked_records": []
},
"adresses": {
"linked_records": [
{
"addressId": 6748337,
"Identification": {
"customerId": "NVS1200063862",
"isPrimary": true,
"addressType": {
"linked_record": {
"code": "200148",
"description": "Primary address",
"shortDescription": null,
"remoteKeys": {
"linked_records": [
{
"system": "200072",
"systemKey": "Primary address",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "5412",
"linkedTable": "/root/RemoteKeys"
}
},
{
"system": "200071",
"systemKey": "Primary address",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "5417",
"linkedTable": "/root/RemoteKeys"
}
},
{
"system": "200073",
"systemKey": "TYS.P",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "5422",
"linkedTable": "/root/RemoteKeys"
}
}
]
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200148",
"foreignKey": "200148",
"linkedTable": "/root/ReferenceData"
}
}
}
},
"AddressAttributes": {
"addressLine1": "D-590 Oxford St E",
"addressLine2": "D",
"addressLine3": null,
"city": "London",
"stateandprovince": {
"linked_record": {
"code": "213040",
"description": "ON",
"shortDescription": "ON",
"remoteKeys": {
"linked_records": [
{
"code": 6672,
"system": "200071",
"systemKey": "ON",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6672",
"linkedTable": "/root/RemoteKeys"
}
},
{
"code": 6685,
"system": "200073",
"systemKey": "009",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6685",
"linkedTable": "/root/RemoteKeys"
}
},
{
"code": 11365,
"system": "209336",
"systemKey": "ON",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "11365",
"linkedTable": "/root/RemoteKeys"
}
}
]
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "213040",
"foreignKey": "213040",
"linkedTable": "/root/ReferenceData"
}
}
},
"zip": "N5Y 3J1",
"country": {
"linked_record": {
"code": "200024",
"description": "Canada",
"shortDescription": "CA",
"remoteKeys": {
"linked_records": [
{
"system": "200071",
"systemKey": "Canada",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6081",
"linkedTable": "/root/RemoteKeys"
}
},
{
"system": "200073",
"systemKey": "CA",
"status": "AC",
"technicalData": {
"lastUser": "moritda3",
"creationTime": "2020-04-22T19:48:08",
"lastTime": "2020-04-22T19:48:08",
"primaryKey": "6082",
"linkedTable": "/root/RemoteKeys"
}
}
]
},
"technicalData": {
"lastUser": "singhv2z",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2020-05-04T06:48:38",
"primaryKey": "200024",
"foreignKey": "200024",
"linkedTable": "/root/ReferenceData"
}
}
}
},
"AdditionalAttributes": {
"brick": "N5Y",
"microbrick": null,
"latitude": null,
"longitude": null,
"height": null,
"geographicCoordinates": null,
"masterAddress": null,
"effectiveDate": "2020-08-06",
"addressStatus": {
"linked_record": {
"code": "200003",
"description": "Active",
"shortDescription": null,
"remoteKeys": {
"linked_records": []
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200003",
"foreignKey": "200003",
"linkedTable": "/root/ReferenceData"
}
}
},
"addressVerificationStatus": {
"linked_record": {
"code": "200032",
"description": "Verified",
"shortDescription": null,
"remoteKeys": {
"linked_records": []
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200032",
"foreignKey": "200032",
"linkedTable": "/root/ReferenceData"
}
}
}
},
"technicalData": {
"lastUser": "sys_apimdmprod",
"creationTime": "2020-08-07T08:01:35",
"lastTime": "2020-08-07T08:01:35",
"primaryKey": "6748337",
"linkedTable": "/root/Address"
}
}
]
},
"education": {
"linked_records": []
},
"specialties": {
"linked_records": []
},
"consent": {
"linked_records": []
},
"credentials": {
"linked_records": []
},
"Affiliation": {
"customerParents": {
"linked_records": [
{
"affiliationId": 5977284,
"parentId": "NVS1200063862",
"childId": "NVS1000143585",
"affiliationType": {
"linked_record": {
"code": "200006",
"description": "HCO-HCP",
"shortDescription": null,
"remoteKeys": {
"linked_records": []
},
"technicalData": {
"lastUser": "chaoure1",
"creationTime": "2019-06-24T11:02:45",
"lastTime": "2019-06-24T11:02:45",
"primaryKey": "200006",
"foreignKey": "200006",
"linkedTable": "/root/ReferenceData"
}
}
},
"startDate": "2020-08-07",
"endDate": null,
"isPrimary": true,
"nanobrick": null,
"role": null,
"technicalData": {
"lastUser": "sys_apimdmprod",
"creationTime": "2020-08-07T08:01:55",
"lastTime": "2020-08-07T08:01:55",
"primaryKey": "5977284",
"linkedTable": "/root/Affiliation"
}
}
]
},
"customerChild": {
"linked_records": []
}
},
"additionalQualification": {
"linked_records": []
},
"statusComment": null,
"Tracking": {
"technicalRecordStatus": "PU",
"producerSystem": "OneKey",
"producerSystemRecordID": "WCAH00083151",
"transactionID": "WORKPLACE_execution3ab77e11c84a403aa12a33c53fafaa4520200807080051163",
"createdDate": "2020-08-07T08:01:27",
"createdBy": "OneKey",
"LastUpdatedDate": "2020-08-07T08:01:35",
"lastUpdateBy": "Api Gateway (sys_apimdmprod)",
"ApprovalDate": null,
"ApprovedBy": null,
"workflowID": null
},
"technicalData": {
"lastUser": "ebx-systemUser",
"creationTime": "2020-08-07T08:01:29",
"lastTime": "2020-09-17T15:41:04",
"primaryKey": "NVS1200063862"
}
}
]
},
"footer": {
"nb_records": 1
}
}
}
I want to create seperate upsert logstash event for each record in records array field.
My Current Logstash configuration looks like below
input
{
jms {
include_header => false
include_properties => false
include_body => true
use_jms_timestamp => false
destination => 'SpringBatchTestQueue'
pub_sub => false
jndi_name => '/JMS/CF/MDM'
jndi_context => {
'java.naming.factory.initial' => 'com.solacesystems.jndi.SolJNDIInitialContextFactory'
'java.naming.security.principal' => 'EDM_Test_User#NovartisDevVPN'
'java.naming.provider.url' => 'tcp://localhost:55555'
'java.naming.security.credentials' => 'EDM_Test_User'
}
require_jars=> ['/app/elasticsearch/jms/commons-lang-2.6.jar',
'/app/elasticsearch/jms/sol-jms-10.10.0.jar',
'/app/elasticsearch/jms/geronimo-jms_1.1_spec-1.1.1.jar']
}
}
filter{
json{
source => "message"
}
split {
field => "[file][body][records]"
}
}
output
{
elasticsearch
{
hosts => ["https://localhost:9200/"]
index => "test-%{+YYYY.MM.dd}"
document_id => "%{customerId}"
doc_as_upsert => true
ssl => true
ssl_certificate_verification => true
cacert => "/app/elasticsearch/config/ssl/Novartis_Silver_Three_Chain.pem"
}
}
Can anyone please let me know how each customerId in recordsfield can be indexed into ES using logstash?
Edit 1: As per answer suggested by Alcanzer.._id field is not populated correctly as well message contains unnecessary fields as well
You'll need to use the split filter to split on [file][body][records]. One use case of the split filter is to take an Array and create 1 event per element in the array.
You'd just add
split { field => "[file][body][records]" }
After your json filter.

From the below json data how can I print the tlds using foreach loop in laravel

Find below my json data and suggest me how to print the tld using foreach loop in laravel. Suggest me how to declare this array structure using foreach loop.
{
"result": "success",
"currency": {
"id": "1",
"code": "INR",
"prefix": " \u20b9",
"suffix": "INR",
"format": "1",
"rate": "1.00000"
},
"pricing": {
"in": {
"categories": [
"ccTLD",
"Geography"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "704.39"
},
"transfer": {
"1": "704.39"
},
"renew": {
"1": "704.39"
}
},
"in.net": {
"categories": [
"Other"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "547.69"
},
"transfer": {
"1": "547.69"
},
"renew": {
"1": "547.69"
}
},
"info": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "861.10"
},
"transfer": {
"1": "861.10"
},
"renew": {
"1": "861.10"
}
},
"org": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "939.45"
},
"transfer": {
"1": "939.45"
},
"renew": {
"1": "939.45"
}
},
"com": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "740.43"
},
"transfer": {
"1": "740.43"
},
"renew": {
"1": "740.43"
}
},
"net": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "829.76"
},
"transfer": {
"1": "829.76"
},
"renew": {
"1": "829.76"
}
},
"biz": {
"categories": [
"gTLD",
"Popular"
],
"addons": {
"dns": true,
"email": true,
"idprotect": true
},
"group": "",
"register": {
"1": "878.33"
},
"transfer": {
"1": "878.33"
},
"renew": {
"1": "878.33"
}
}
}
}
From the above data I wanted to display the tlds such as in,in.net,org,info,com,net,biz.
Use this:
$tlds = array_keys(json_decode($json, true)['pricing']);

Resources