How to add a children data through user exit class in Maximo inbound integration? - integration

I have an object structure with 3 objects. location > lochierarchy > customtable.
On the original source xml -erdata, I get only details for location object. I have derived the information for lochierarchy and the customtable.
If I have at least one column value for lochierarchy and customtable, I am able to use the following code and fill up the derived values.
xml
<LOCATIONS>
<location>1000</location>
<siteid>xyg</siteid>
<LOCHIERARCHY>
<SYSTEMID>abdc</SYSTEMID>
<PARENT></PARENT>
<CUSTOMTABLE>
<DEPT>MECHANICAL</DEPT>
<OWNER></OWNER>
</CUSTOMTABLE>
</LOCHIERARCHY>
List locHierarchyList =irData.getChildrenData("LOCHIERARCHY");
int locHrSize=locHierarchyList.size();
for (int i=0;i<locHrSize;i++)
{
irData.setAsCurrent(locHierarchyList,i);
irData.setCurrentData("PARENT","xyyyyg");
List customTablerList =irData.getChildrenData("CUSTOMTABLE");
int custSize=customTablerList .size();
for (int i=0;i<custSize;i++)
{
//set values
}
But I am getting the source xml with only the location data below and I'm trying to build the children data. I am missing something here.
Incoming XML
<LOCATIONS>
<location>1000</location>
<siteid>xyg</siteid>
</LOCATIONS>
My Code
irData.createChildrenData("LOCHIERARCHY");
irData.setAsCurrent();
irData.setCurrentData("SYSTEMID", SYSTEM);
irData.setCurrentData("PARENT", parentLoc);
irData.createChildrenData("CUSTOMTABLE");
irData.setAsCurrent();
but this is not working. Can anyone help me out?

got it, just had to use another method of createChildrenData.
irData.createChildrenData("LOCHIERARCHY",true);
This one did the trick. It creates the child set and make it as current.

Related

Updating Data within a unique randomly generated ID/KEY in firebase using HTML

function updateFirebase(){
const fb=firebase.database().ref()
//get field values
author = document.getElementById('uname').value
user_email = document.getElementById('umail').value
data = {author, user_email}
//update database
fb.child('Article/').update(data);
}
</script>
I have problem with my code. I want to update the data inside a table named "Article". Article has generated items with a unique key/id and each key has its own content. Lets say I want to be able to edit the "author" or change the "title", the problem is they each have a randomly generated key/id that I cant access. for example that "-LS39kReBHrKGqNj7h_". I can only save the data inside the "Article" tree but I cant change the "author" or the "title". How do i get a workaround this so I can change those properties?
Here is how my firebase looks like
It depends whether you have the record reference on the frontend before update or not (whether you have fetched it before you are trying to update it).
But generally, you have two options
You can store the key reference as an "id" field on the object.
To achieve that, you need two step process when creating the record at the first place
// Creates a new record in DB and returns it to you. Now you can get the "key"
const newRecord = firebase.database().ref('TABLE_NAME_REF').push();
newRecord.set({
id: newRecord.key
...
});
This is great if you fetch the list of records on the frontend and then you want to update one of them. Then you can just build the ref path like this
fb.child('Article/' + record.id ).update(data); // where record is the prefetched thing
You need to find the element based on its fields first. And once you have it, you can update it right away.
To achieve this, you can simply do something like:
firebase.database()
.ref('TABLE_NAME_REF') // let's say 'Article'
.orderByChild('RECORD_KEY') // Let's say 'author'
.equalTo('KEY_VALUE') // let's say 'zoranm'
.limitToFirst(1)
.once("value")
.then(res => {
// You need to loop, it always returns an array
res.forEach(record => {
console.log(record.key); // Here you get access to the "key"
fb.child('Article/' + record.key ).update(data); // This is your code pasted here
})
})

Populate the tabs and the form in each tab dynamically

I am extracting data from the server and from that data I need to create the number of tabs and populate the data in the form of each tab.
For e.g.:
If my data has two fields named 'x' and 'y' then I need to create two tabs (where the form panel, meaning the fields inside the tab, are same) and then I need to populate these fields with the appropriate data.
Populating the data is fine but I need to know how to add tabs dynamically according to the JSON object I get. The name of the tab I'll be getting from the JSON object.
EDIT:
The JSON looks like this:
{
..
events : {
'X JOINED' : {
..
}
'Y JOINED' : {
..
}
}
}
Now I need two tabs named 'X JOINED' and 'Y JOINED' with the '..' giving the data to populate inside the tabs.
If you have a tabpanel you can use the method add to add a new tab.
To know the names of your object, just use the js keys method on your object obtained from JSON.
It will look something like that :
for(var prop in myObject)
myTabPanel.add(Ext.define("tab", {title: prop}));
do you have an sample of your JSON object?

how to read/interpret json file to define mysql schema

I have been tasked with mapping a json file to a mysql database and I am trying to define the appropriate schema a sample of the json file is below
"configurationItems":[
{
"ARN":"",
"availabilityZone":"",
"awsAccountId":"hidden from sight ",
"awsRegion":"",
"configuration":{
"amiLaunchIndex":,
"architecture":"",
"blockDeviceMappings":[
{
"deviceName":"",
"ebs":{
"attachTime":"",
"deleteOnTermination":true,
"status":"attached",
"volumeId":""
}
}
],
"clientToken":"",
"ebsOptimized":,
"hypervisor":"",
"imageId":"",
"instanceId":"",
"instanceType":"",
"kernelId":"aki-",
"keyName":"",
"launchTime":"",
"monitoring":{
"state":""
},
"networkInterfaces":[
{ etc
am I right in thinking that the way to do this is essentially wherever there is a bracket /child element there would be a new table eg; configuration items down to aws region would be in a table then configuration through architecture followed by block device mappings etc etc if that is the case then where would the client token through lanch time belong ? many thanks in advance folks
That certainly is a way to use it.
It gives a more parent child relation approach to the setup.
E.g.
"blockDeviceMappings":[
{
"deviceName":"/dev/sda1",
"ebs":{
"attachTime":"2014-01-06T10:37:40.000Z",
"deleteOnTermination":true,
"status":"attached",
"volumeId":""
}
}
]
Probably could have more than one devices so it would be a 1 to many relation.

Accessing attributes of a json

I have this JSON output
{
"status":1,
"complete":1,
"list":{
"792489954":{
"item_id":"792489954",
"resolved_id":"792489954",
"given_url":"http:\/\/www.liveathos.com\/?gclid=Cj0KEQiAzb-kBRDe49qh9s75m-wBEiQATOxgwZcJ5_ws34o4PUSUYDGqs8HEbLF-LyjxrTPOwn6AYV8aAmMk8P8HAQ",
"given_title":"Athos - Wearable Technology for Fitness",
"favorite":"0",
"status":"0",
"time_added":"1418754744",
"time_updated":"1418754746",
"time_read":"0",
"time_favorited":"0",
"sort_id":0,
"resolved_title":"Wearable Technology for Fitness",
"resolved_url":"http:\/\/www.liveathos.com\/?gclid=Cj0KEQiAzb-kBRDe49qh9s75m-wBEiQATOxgwZcJ5_ws34o4PUSUYDGqs8HEbLF-LyjxrTPOwn6AYV8aAmMk8P8HAQ",
"excerpt":"Thank you for reserving Athos. You will receive a confirmation email with reservation details and a referral link where you get $10 off your next order.",
"is_article":"0",
"is_index":"0",
"has_video":"0",
"has_image":"0",
"word_count":"25"
},
"692647226":{
"item_id":"692647226",
"resolved_id":"692647226",
"given_url":"http:\/\/www.terrafugia.com\/news",
"given_title":"News | Terrafugia",
"favorite":"0",
"status":"0",
"time_added":"1418754204",
"time_updated":"1418754204",
"time_read":"0",
"time_favorited":"0",
"sort_id":1,
"resolved_title":"News",
"resolved_url":"http:\/\/www.terrafugia.com\/news",
"excerpt":"",
"is_article":"0",
"is_index":"1",
"has_video":"0",
"has_image":"0",
"word_count":"0"
},
`...etc` "since":1419641101
};
It's a JSON with a list that should have article items on it. I want to access the properties of these smaller items like given_url.
I'm using
for key in (BIGJSONRESPONSE).list
do etc...
When I try printing the key, I get only the id that comes before an item. Any idea how to access more?
Thanks!
You asked for the keys, you got the keys. To get the item associated with that key, use BIGJSONRESPONSE.list[key].
This should be correct:
for in returns the keys of an object. Since the key refers to a property of the object one can access the property using [key].
for (key in (BIGJSONRESPONSE).list)
{
console.log(BIGJSONRESPONSE.list[key]) // log the entry to console for debugger.
}

Problems with render Criteria as json in Grails!Find one field in a restfull service and render it

I have this code.I want to have some rows in JSON,to find it Im trying to use criteria. I want render each case as json.
Example: I want the row of my table that have Name:"pepito" .if I put params.nombre, but I want this only this row in JSON how can I do that?
Im trying to do that with findbyNombre(params.nombre) but if I put some if/else with his conditions it doesnt found.
Please,can somebody help me????I have to give my code for a job and Im lost!!!
THANKS!
case "GET":
def criterios=CatalogoJson.createCriteria().list() {
if (params.nombre) {
eq('nombre', params.nombre)
// render CatalogoJson.findByNombre(params.nombre)as JSON
}
if(params.id) {
eq('id', CatalogoJson.findById(params.id))
}
}
render criterios as JSON
break
I might not have got the question correctly as to what is expected. My assumption is that, you would have either of the params (either nombre or the Id or both) available in the request. Based on that assumption you can have the criteria implemented as below. Note:- I used toInteger() as you mentioned the datatype as int, generally ids are Long in conjunction with GORM and Hibernate persistence layer.
def criterios = CatalogoJson.createCriteria().listDistinct {
if(params.id) {
idEq(params.id.toInteger())
}
if (params.nombre) {
eq('nombre', params.nombre)
}
}
render criterios as JSON
UPDATE
Ok let me try this one more time. Again if I have followed you incorrectly, let me know.
The way you are expecting to map url is not RESTful. Instead, there is one best way to implement what you are expecting in the REST service:-
Pleasant way OR I-like-it-this-way
The url mapping should look like
"/catalog/$id?"(resource: 'catalog')
//Controller Action:-
def show(){
def criterios = CatalogoJson.createCriteria().list {
if(params.id) { //check 1
idEq(params.id.toInteger())
} else if(params.name) { //check 2
eq('name', params.name)
} else if(params.year){ //check 3
eq('year', params.year)
} else if(params.others){ //check 4
eq('others', params.others)
} //so on an so forth //Can also use Switch case if you want
}
render criterios as JSON
}
Use case:-
http://mydomain.com/catalog/134 --> should set the id to 134 and check 1 will be evaluated
http://mydomain.com/catalog?name=Pep --> should set the name to Pep and check 2 will be evaluated
http://mydomain.com/catalog?year=1987 --> should set the year to params as 1987 and check 3 will be evaluated
Inference-
Use of named query parameters to itemize your parameters with respect to your need in REST service and domain. If you want to use unnamed parameters then the url mapping would look like:
"/catalog/$id/$name?/$year?/$others?"(resource: 'catalog')
The problem in this approach is that your url should look like
http://mydomain.com/catalog/134
http://mydomain.com/catalog/134/Pep
http://mydomain.com/catalog/134/Pep/1987
Your optional parameters are no more optional. Have a look at Optional Variables in URL mapping