Call a WebService if value not found in an XML result - talend

From a MySQL query, I am trying to iterate on every rows to:
Test the existence of an object using a webservice
Then if the object doesn't exist yet, I will add it using another webservice, otherwise I do nothing.
Update in any case a MySQL DB table.
Here is what I've done so far:
First I create the connection
I get the columns I need from my MySQL query
I start iterating
I call my webservice which give me a String holding XML (column name: ResultXML)
I extract from this XML the values I need (column name: ResultExtract)
Then I want to test if one of the values extracted is equal to a specific value (let's say 10).
So from my my tExtractXMLField, I get something like :
150
10
So this would mean that I won't have called the 2nd webservice.
I can't find how to look for my value in the result (the result can also be empty and then no row would come from the tExtractXMLField).
I tried to use a tJava after the tExtractXMLField component to split my result as a List but the tJava component is running before the 1st webservice has finished so I get NULL.
Maybe there is a better way to do what I've already done, and if so, I am also pleased to receive your recommandation.

Related

PowerShell script to update SharePoint Online list items does not save all column values

I'm processing a CSV file to create SharePoint Online list items and save metadata as fields in its custom content type. At first, I thought it would be an issue related to column type, but I'm failing to save some simple text field values. What's puzzling is that I am able to save some but not other fields - even though I'm using the same means to do this - somehow the list item is not preserving all the values I send in for the list item update.
I create a new item with the following code:
$newFile = $targetfolderObj.Files.Add($FileCreationInfo)
$targetContext.Load($newFile)
$spContext.ExecuteQuery()
Then I get the list item and start setting the field values
$newFileListItem = $newFile.ListItemAllFields
$newFileListItem.Properties["ColumnNameA"] = $_.CustomValue1 # saves
$newFileListItem.Properties["ColumnNameB"] = $_.CustomValue2 # not saving !!!
$newFileListItem.Properties["ColumnNameC"] = $_.CustomValue3 # saves
After setting up the properties with values I call the update and execute functions.
$newFileListItem.Update()
$spContext.ExecuteQuery()
$.CustomValue1 $.CustomValue2 and $_.CustomValue3 when printed all read as "Hello" for example, there are no special characters or symbols here - even hardcoding the field values to simple strings will fail to update field 2 but works on 1 and 3.
I am giving this example with my code to show it's not sequential - for example field 2 data is NOT saved but field 1 and 3 data is saved.
It always fails on the same columns, I verified the columns exist, I'm using the internal field names, string length is well within range, and there is no other validation applied on these columns. What could I possibly do to troubleshoot this?
After a lot of debugging, I'm seeing SharePoint funnery at play...
while the content type is there, and the content type internal field name is "ColumnNameA" something must have gone sideways in the library instance, causing the column name to now be "ColumnNameA0" yes, a zero added at the end of the column name. Every column that was not updating had somehow now a "zero" at the end of the internal column name.
Solution 1: add the zero
Solution 2: recreate the library and re-associate it with the site conten type
I went with Solution 1 to test that my updates worked, then rebuilt the library.

Loop through database ANYLOGIC

In my model I want to loop through the database which contains multiple columns (see example) by an event. The idea behind it is that I want to create dynamic events based on the rows in the database.
But I've no clue how to iterate through a database in anylogic and also was not able to find an example of a loop with a database.
The dummycode of my problem would look something like this:
For order in orderdatabase:
Create order based on (order.name, order.quantity, order.arrivaltime, order.deliverylocation)
Where order in the loop is every row of the database, and the value on which the creation is based based on the different column values of that specific row.
Can somebody give me a simple example of how to create such a loop for this specific problem.
Thanks in advance.
Use the database query wizard:
put your cursor into a code field
this will allow you to open the database wizard
select what you need (in your case, you want the "iterate over returned rows and do something" option
Click ok
adjust the dummy code to make it do what you want
For details and examples, check the example models and the AnyLogic help, explaining all options in detail.

Getting the underlying data in tableau

The data representation was created in Tableau and I am accessing and showing it on my website through the Tableau JS API: link to the API.
Obtaining the viz and showing my Tableau have already been done. I have a Bar Chart showing my data in horizontal columns. The idea is that I want to be able to click on a column and then get the data which goes into this column.
Let's say we have 12 elements. They are represented by 3 columns. The first column has 5, the second 3 and the third 4 elements. In my case, after selecting the column with 4 elements I would want to be able to get the underlying 4 data entries.
I have been going through the API Documentation (link) and I have added on click listener for marksSelection. However, it only returns me the "sorting conditions" so to say. I tried getting the getUnderlyingDataAsync and then getData() but the returned data is not really in a format which I can use (since there are only pairs of row and column and not the full data entries).
Is something like this possible?
I solved it in a couple of steps following the API:
getUnderlyingDataAsync to obtain a DataTable, save it to an object called dataTable.
Get all of the (raw) data by calling dataTable.getData(). It returns a 2D array. To help you imagine the structure, let's say that the data source has 50 objects then the array will have a length of 50. If each object has 5 properties then the nested array will have a length of 5 (with each property represented as 1 element).
Get all of the columns by calling dataTable.getColumns(). Here you will need the name and index properties.
Create an object containing our actual JSON data by combining the columns in (3) and the (raw) data from (2).
Now you should have a structured array of objects.

BIRT - Remove empty row from parameter

I have two cascading parameters that need to be set before you generate the report.
The first one is an ID I am selecting and the the second one can be a list of values (an array) that are linked to the first ID.
I have managed the array with this line on the beforeOpen script
this.queryText=this.queryText.replace("999",params["ID_BOBJECT"].value.join(","));
and my query looks like this:
SELECT V_MOUVEMENT_1.*
FROM V_MOUVEMENT_1
WHERE V_MOUVEMENT_1.ID_BOBJECT IN (999)
My problem is that in the end, the list of my second parameter has a blank value first and when I am creating the list selecting all the values (including the empty one) I get an error that the value is not specified:
Example
Well, the only solution that worked is only this one:
Solution
Too bad it works only from eclipse...
If I deploy my rptdesign to another application, it doesn't work anymore.

restrict duplicate entry,iphone

HI All,
i am inserting , say name to sqlite, than showing it on tableview.
But i want say restrict user to insert duplicate name.
for first time data gets inserted perfectly, but when i insert it on second time, it again get inserted, thats what i want to prevent.
HOw can i check if the value 'name' already exist in sqlite and show alert to tell user that this value already exist.
edited
i have an array abc , having few values., values in array i am adding from another view, now say if abc contains value "a1", now if i again inserting "a1", it should not except "a1", in a way how i can restrict an array to add duplicate value.
regards
Use unique constraint in your SQL database. Here's a link with some basics on it. Here's some specifics on how to create table with unique contraints with SQLite.
To alert users, just capture the error message from your SQL query and then output as needed.
Edited (for new question):
Easiest way is to parse through the array and do duplicate checks. There's logic out there for faster searching but if you have a small array, then all you really need is a for loop that iterates through each array element and checks that the new value you are adding is not already there.