I have this sample json data:
{
"sessionsData" :[{
"isActive": true,
"isInactive": false,
"isScheduled": false,
"isExpired": false,
"candidateName":"Payal Singh",
"email": "ggera#sapient.com"
},
{
"isActive": false,
"isInactive": true,
"isScheduled": false,
"isExpired": false,
"candidateName":"Shyam Singh",
"email": "ggera#sapient.com"
},
{
"isActive": false,
"isInactive": false,
"isScheduled": true,
"isExpired": false,
"candidateName":"Payal Singh",
"email": "ggera#sapient.com"
},
{
"isActive": false,
"isInactive": false,
"isScheduled": false,
"isExpired": true,
"candidateName":"Payal Singh",
"email": "ggera#sapient.com"
}]
}
Now I want to count only the entries which have "isActive" property set to true by using angular.
Anyone have any suggestions?
arr.sessionsData.filter(function(obj,key){
return obj.isActive==true
})
OR:
ECMA6 :
var arrFiltered = arr.sessionsData.filter((obj,key)=>
obj.isActive==true
)
https://docs.angularjs.org/api/ng/filter/filter. Follow this link, it is very detailed.I went around it like this:
$scope.activeEntries = $filter('filter')($scope.session.sessionsData, {isActive: true});
where $scope.session.sessionsData is the array in which I retrieved the json data.
Related
I've got the response from HTTP GET request as JSON object and I want to use that JSON and put other node pass it to the next HTTP request. I got the following response data
{
"settlementFolio": "0002",
"settlementID": 283,
"businessUnitID": 43,
"routeID": 955,
"chargeAmount": 22248.0000,
"paymentAmount": 68560.6000,
"isPaid": false,
"hasValidCrewConfiguration": true,
"settlementDate": "2020-09-21T00:00:00",
"charged": 68560.6000,
"packageRemain": 7500.0000,
"totalBoxes": 280,
"detail": [
{
"settlementTransactionID": 1,
"settlementTransactionDescription": "1 Ventas Netas",
"charge": 0.0,
"payment": 61060.6000,
"isAutomatic": true,
"isForClient": false,
"isCharge": false,
"isChecked": false,
"settlementTransactionClientDetail": [
{
"settlementTransactionID": 3456,
"clientID": 392342,
"saleNote": 11792,
"amount": 30530.3000,
"reference": "",
"clientName": "OXXO NUEVA MAYAPAN",
"isChecked": false
},
{
"settlementTransactionID": 3456,
"clientID": 391322,
"saleNote": 11793,
"amount": 30530.3000,
"reference": "",
"clientName": "OXXO CHICHI SUAREZ",
"isChecked": false
}
]
}
],
"productTypeCounter": [
{
"centralCostID": 1,
"centralCostName": "Refrescos",
"sellUnit": 280,
"cNomina": 0.0000
}
]
}
I need to append a node like this with "settlementTransactionID": 2,
{
"settlementFolio": "0002",
"settlementID": 283,
"businessUnitID": 43,
"routeID": 955,
"chargeAmount": 22248.0000,
"paymentAmount": 68560.6000,
"isPaid": false,
"hasValidCrewConfiguration": true,
"settlementDate": "2020-09-21T00:00:00",
"charged": 68560.6000,
"packageRemain": 7500.0000,
"totalBoxes": 280,
"detail": [
{
"settlementTransactionID": 1,
"settlementTransactionDescription": "1 Ventas Netas",
"charge": 0.0,
"payment": 61060.6000,
"isAutomatic": true,
"isForClient": false,
"isCharge": false,
"isChecked": false,
"settlementTransactionClientDetail": [
{
"settlementTransactionID": 3456,
"clientID": 392342,
"saleNote": 11792,
"amount": 30530.3000,
"reference": "",
"clientName": "OXXO NUEVA MAYAPAN",
"isChecked": false
},
{
"settlementTransactionID": 3456,
"clientID": 391322,
"saleNote": 11793,
"amount": 30530.3000,
"reference": "",
"clientName": "OXXO CHICHI SUAREZ",
"isChecked": false
}
]
},
{
"settlementTransactionID": 2,
"settlementTransactionDescription": "2 Envase Faltante",
"charge": 0.0,
"payment": 7500.0000,
"isAutomatic": true,
"isForClient": false,
"isCharge": false,
"isChecked": false,
"settlementTransactionClientDetail": [
{
"settlementTransactionID": 3461,
"clientID": 0,
"saleNote": null,
"amount": 7500.0000,
"reference": "202|75.00|100.000",
"clientName": "",
"isChecked": false
}
]
}
],
"productTypeCounter": [
{
"centralCostID": 1,
"centralCostName": "Refrescos",
"sellUnit": 280,
"cNomina": 0.0000
}
]
}
I am using something like this
String addMore = '${detail}';
def detail = new groovy.json.JsonSlurper().parseText(addMore);
detail.put(deposito);
vars.put("detail", new groovy.json.JsonBuilder(detail).toPrettyString());
log.info("",vars.get('detail'));
The log shows the following error
020-09-23 09:09:25,857 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223 PostProcessor
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.put() is applicable for argument types: (org.apache.groovy.json.internal.LazyMap) values: [[settlementTransactionID:11, settlementTransactionDescription:11 Deposito de Efectivo, ...]]
Possible solutions: sum(), pop(), get(int), get(int), sum(java.lang.Object), plus(java.lang.Object)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.3.jar:3.0.3]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.3.jar:3.0.3]
at javax.script.CompiledScript.eval(CompiledScript.java:89) ~[java.scripting:?]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:222) ~[ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:45) [ApacheJMeter_components.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:940) [ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:572) [ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.3]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.3]
at java.lang.Thread.run(Thread.java:832) [?:?]
Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.put() is applicable for argument types: (org.apache.groovy.json.internal.LazyMap) values: [[settlementTransactionID:11, settlementTransactionDescription:11 Deposito de Efectivo, ...]]
Possible solutions: sum(), pop(), get(int), get(int), sum(java.lang.Object), plus(java.lang.Object)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70) ~[groovy-3.0.3.jar:3.0.3]
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46) ~[groovy-3.0.3.jar:3.0.3]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-3.0.3.jar:3.0.3]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-3.0.3.jar:3.0.3]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) ~[groovy-3.0.3.jar:3.0.3]
at Script158.run(Script158.groovy:31) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.3.jar:3.0.3]
... 9 more
We cannot help you as it's unclear what are these ${detail} and ${deposito} mean and contain.
If you get a deposito JMeter Variable which looks like:
{
"settlementTransactionID": 2,
"settlementTransactionDescription": "2 Envase Faltante",
"charge": 0.0,
"payment": 7500.0000,
"isAutomatic": true,
"isForClient": false,
"isCharge": false,
"isChecked": false,
"settlementTransactionClientDetail": [
{
"settlementTransactionID": 3461,
"clientID": 0,
"saleNote": null,
"amount": 7500.0000,
"reference": "202|75.00|100.000",
"clientName": "",
"isChecked": false
}
]
}
and you want to add it to the response of a certain sampler and store the result into another JMeter Variable you can use JSR223 PostProcessor with the following code:
def originalResponse = new groovy.json.JsonSlurper().parse(prev.getResponseData())
originalResponse.detail.add(new groovy.json.JsonSlurper().parseText(vars.get('deposito')))
vars.put('modifiedResponse', new groovy.json.JsonBuilder(originalResponse).toPrettyString())
assuming everything goes well you will get the JSON payload you're looking for in the ${modifiedResponse} JMeter Variable.
More information:
Apache Groovy - Parsing and producing JSON
Apache Groovy - Why and How You Should Use It
Iam new to geoserver. I have created shape file of my district and added certain attributes like covid count, covid zone , district name etc related to COVID . I have loaded this to postgis database and I could see attributes also in table .But when I try to retrieve the feature using postman . Attribute values are not retrieved. Can anyone help
Below is my request
http://localhost:8080/geoserver/rest/workspaces/DistrictWpc/datastores/district_store/featuretypes/ernakulam.json
Response is
{
"featureType": {
"name": "ernakulam",
"nativeName": "ernakulam",
"namespace": {
"name": "DistrictWpc",
"href": "http://localhost:8080/geoserver/rest/namespaces/DistrictWpc.json"
},
"title": "ernakulam",
"keywords": {
"string": [
"features",
"ernakulam"
]
},
"srs": "EPSG:404000",
"nativeBoundingBox": {
"minx": 76.1618881225586,
"maxx": 76.6080093383789,
"miny": 9.63820648193359,
"maxy": 10.1869020462036
},
"latLonBoundingBox": {
"minx": 76.1618881225586,
"maxx": 76.6080093383789,
"miny": 9.63820648193359,
"maxy": 10.1869020462036,
"crs": "EPSG:4326"
},
"projectionPolicy": "FORCE_DECLARED",
"enabled": true,
"store": {
"#class": "dataStore",
"name": "DistrictWpc:district_store",
"href": "http://localhost:8080/geoserver/rest/workspaces/DistrictWpc/datastores/district_store.json"
},
"serviceConfiguration": false,
"maxFeatures": 0,
"numDecimals": 0,
"padWithZeros": false,
"forcedDecimal": false,
"overridingServiceSRS": false,
"skipNumberMatched": false,
"circularArcPresent": false,
"attributes": {
"attribute": [
{
"name": "id",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": true,
"binding": "java.lang.Long"
},
{
"name": "district",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": true,
"binding": "java.lang.String"
},
{
"name": "count",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": true,
"binding": "java.lang.Long"
},
{
"name": "zone",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": true,
"binding": "java.lang.String"
},
{
"name": "geom",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": true,
"binding": "org.locationtech.jts.geom.MultiPolygon"
}
]
}
}
}
GeoServer's REST API is used for administrative tasks and as such does not provide a way to see the actual data you have stored in the database, just the details of how GeoServer is connecting to the database and some metadata about the store.
To access the actual data you need to use the WFS endpoint which is described by the OGC WES Specification and described in the GeoServer manual.
If you must have REST access to the features you could use the experimental OGC Features API module to do this.
I am using IPFS and trying to understand its structure.
ISSUE: 1
The issue I am facing is that when I am trying to shrink the storage size of IPFS (for testing it is taking so long time, hence I just want to shrink File System for a while) but is unable to shrink.
I tried to configure the config file by changing the StorageMax limit
using this command
ipfs config Datastore.StorageMax 1GB
but still it does not work, it accepting (ipfs add ) the files after the 1GB also, why he is not limiting the file-storage?
anyone, please suggest me How to reduce file-system size?
ISSUE: 2
Even in case of IPFS's default storage limit (Which is 10 GB), I saw when I am adding the files on IPFS it is not stopping to store files after crosses 10GB (which was limit).
It should not be cross after the limit ends, for this what to do?
below is the config file
{
"API": {
"HTTPHeaders": {}
},
"Addresses": {
"API": "/ip4/0.0.0.0/tcp/5001",
"Announce": [],
"Gateway": "/ip4/0.0.0.0/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
},
"Bootstrap": [
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbBhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2MULpjvfd3aZ6ha4oFGL1KrGM",
"/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXDQVcqN88CNLHXMkTNwMKPnu",
"/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZCy3U6aXMJDAbzgu2fzaDs64",
"/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPakiS1J6DifTC88f5uVQKNAd",
"/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M7Lpjvfd3aZ6ha4oFGL1KrGM",
"/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctVcqN88CNLHXMkTNwMKPnu",
"/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
"/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"
],
"Datastore": {
"BloomFilterSize": 0,
"GCPeriod": "1h",
"HashOnRead": false,
"Spec": {
"mounts": [
{
"child": {
"path": "blocks",
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
"sync": true,
"type": "flatfs"
},
"mountpoint": "/blocks",
"prefix": "flatfs.datastore",
"type": "measure"
},
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
}
],
"type": "mount"
},
"StorageGCWatermark": 0,
"StorageMax": "1GB"
},
"Discovery": {
"MDNS": {
"Enabled": true,
"Interval": 10
}
},
"Experimental": {
"FilestoreEnabled": false,
"Libp2pStreamMounting": false,
"P2pHttpProxy": false,
"QUIC": false,
"ShardingEnabled": false,
"UrlstoreEnabled": false
},
"Gateway": {
"APICommands": [],
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With",
"Range"
],
"Access-Control-Allow-Methods": [
"GET"
],
"Access-Control-Allow-Origin": [
"*"
]
},
"PathPrefixes": [],
"RootRedirect": "",
"Writable": false
},
"Identity": {
"PeerID": "QmfB8xVzjndgMWHuxszYADGrwBo1Zx6zjBQQCsqARDupsW"
},
"Ipns": {
"RecordLifetime": "",
"RepublishPeriod": "",
"ResolveCacheSize": 128
},
"Mounts": {
"FuseAllowOther": false,
"IPFS": "/ipfs",
"IPNS": "/ipns"
},
"Pubsub": {
"DisableSigning": false,
"Router": "",
"StrictSignatureVerification": false
},
"Reprovider": {
"Interval": "12h",
"Strategy": "all"
},
"Routing": {
"Type": "dht"
},
"Swarm": {
"AddrFilters": null,
"ConnMgr": {
"GracePeriod": "20s",
"HighWater": 900,
"LowWater": 600,
"Type": "basic"
},
"DisableBandwidthMetrics": false,
"DisableNatPortMap": false,
"DisableRelay": false,
"EnableRelayHop": false
}
}
It looks like StorageMax does not actually limit the size of the IPFS node, instead it's used to determine whether or not to run garbage collection. IPFS will write until the disk is full.
I'm making a dynamic registration form My dynamic form example. The data written in those inputs will be later sent to some API.
<div ng-repeat="item in CustomRegistrationForm"
class="form-group text-field-para" style="margin: 10px">
<input type="{{item.Type}}" id="{{'A'+$index}}"
class="form-control" name="{{TmpName}}"
ng-model="RegistationSubscriberData.User.CustomRegistrationForm[$index].Name">
</div>
CustomRegistration is a JSON made like this: https://jsoneditoronline.org/?id=5396efadcf9d475a9fee6e558e8b807c .
By my logic ng-models would have to be set (in my case) as: "FirstName", "Email", "GSMnumber",... But it just saves as the last string in the ng-model, in my case "Name". I tried to use item.Name also but it didn't make any difference. Also if I tried to "console.log(CustomRegistration[0].Name)" it worked perfectly and output "FirstName"
Can someone explain to me why in this case my 'type' works perfectly (Dynamicly) but ng-model can't work with dynamic variable. This is my first question here so if I made any mistakes I apologise in advance.
You have to create array for the ng-model then you can add dynamically into that array as below.
<div ng-app ng-controller="TestController">
<div ng-repeat="item in CustomRegistrationForm" class="form-group text-field-para" style="margin: 10px">
<input type="{{item.Type}}" id="{{'A'+$index}}"
class="form-control" name="{{TmpName}}"
ng-model="Users[item.Name]">
</div>
<p> {{Users}} </p>
</div>
In Controller
function TesyController($scope) {
$scope.RegistationSubscriberData = {};
$scope.CustomRegistrationForm = [
{
"Label": "First name",
"Name": "FirstName",
"Type": "text",
"Mandatory": true,
"Length": 20,
"showPlaceHolder": false,
"Regex": "/^[a-z ,.'-]+$/i",
"Validator": "",
"requireRetypePassword": false,
"strengthValidatorEnabled": false,
"strengthComplexityLevel": false,
"Format": ""
},
{
"Label": "Email",
"Name": "Email",
"Type": "email",
"Mandatory": true,
"Length": "",
"showPlaceHolder": false,
"Regex": "",
"Validator": false,
"requireRetypePassword": false,
"strengthValidatorEnabled": false,
"strengthComplexityLevel": false,
"Format": ""
},
{
"Label": "Phone number (international format)",
"Name": "GSMNumber",
"Type": "text",
"Mandatory": false,
"Length": "",
"showPlaceHolder": false,
"Regex": "/^[a-z ,.'-]+$/i",
"Validator": "",
"requireRetypePassword": false,
"strengthValidatorEnabled": false,
"strengthComplexityLevel": false,
"Format": ""
},
{
"Label": "Password",
"Name": "password",
"Type": "password",
"Mandatory": true,
"Length": "",
"showPlaceHolder": false,
"Regex": "",
"Validator": false,
"requireRetypePassword": true,
"strengthValidatorEnabled": true,
"strengthComplexityLevel": false,
"Format": ""
}
]
}
For reference you can refer below fiddle links
fiddle
fiddle 2
Hope this will help you.
All the question is in my title =).
I started with checkBox Tree exemple, add property checked:false for the first level that work i see my checkbox just on left icone folder.
But have radio in level that is so different, i tryed some change to transform checkbox in radio, but nothing *:_:*
Some topic given by broogle talk only some levels with checkbox but none with radio.
Have you an idea ?
Thx a lot, have a nice day.
The Example is using a JSON file to load the nodes.
In de JSON file you can set "checked" to true or false.
{"text": "Grocery List",
"cls": "folder",
"children": [{
"text": "Bananas",
"leaf": true,
"checked": false
},{
"text": "Milk",
"leaf": true,
"checked": false
},{
"text": "Cereal",
"leaf": true,
"checked": false
},{
"text": "Energy foods",
"cls": "folder",
"children": [{
"text": "Coffee",
"leaf": true,
"checked": false
},{
"text": "Red Bull",
"leaf": true,
"checked": false
}]
}]}
You can only have a checkbox in the tree but you can always write your own extension :)
Well, i'm brb on this thread for give a little function. put that on your tree and normaly you have checkbox with radio behavior.
listeners: {
'checkchange': function( n, check )
{
if( check )
{
var p = n.parentNode;
p.eachChild( function( c )
{
if( c.isLeaf() && c.get('checked') )
{
c.set('checked', false);
}
});
n.set('checked', true);
}
else
{
n.set('checked', false);
}
}
}