Very new to web services (as you can tell from the Q) so i am pretty sure this is a basic question.
I am sending the request of to the server
ExecuteSQLQueryReq sqlParams = new ExecuteSQLQueryReq();
sqlParams.setSql(sqlState.getNoDevInDP("LIV_Phones_DP"));
and getting the response i expect:
ExecuteSQLQueryRes getSqlResult = axlPort.executeSQLQuery(sqlParams);
i can see all the data is there in the object from the eclipse debugging
but from the object "getSqlResult" i dont know how to pull the data out. The response is in the following format:
Any help would be great
Thanks
Alexis
EDIT:
Screen shot of "ExecuteSQLQueryRes". The only methods i see is to return a list of Objects, which i do and that the screenshot of the variables in eclipse you mention. Its the next step .... how to get from a generic Object the data out..
From the type signatures, I'd say you would invoke the service like so:
List<Object> rows = axlPort.executeSQLQuery(sqlParams)
.getReturn()
.getRow();
for(Object row : rows) {
Element rowElement = (Element) row;
// utilize DOM API
}
As far as I can tell from the information posted you're getting a List of Elements. In XML:
<row>?</row>
<row>?</row>
<row>?</row>
Since row is anyType nothing specific can be inferred about its structure. In the specific case, the first entry looks like this assuming a single child (text) node:
<row>339</row>
You can use the Java DOM APIs to access the data.
From the name onwards, this service looks like it just exposes the underlying database implementation. Consider adhering to stricter SOA principles if you have any influence over the service design.
Related
I have Actor and Sequences as life lines in my sequence diagram in Enterprise Architect.
.
This diagram has a fragment also in it. I tried to fetch the diagram object through java API.
I'm able to get all the Actor, Sequence and Fragment information from the API. But I am unable to differentiate which among these are life lines.
Is there any way to differentiate Lifelines and other elements through API or through EA Database?
Little more hint about how to approach this problem would be more appreciated.
Code snippet that i'm using as follows
.
.
Diagram sequenceDiagram = rep.GetDiagramByGuid(seqdiagGuid);
Collection<DiagramObject> diagObjs = sequenceDiagram.GetDiagramObjects();
for (DiagramObject obj : diagObjs) {
Element el = rep.GetElementByID(obj.GetElementID());
// How to differenciate whether this el is a lifeline?
}
Edited with few more information and screen shots to give some more clarity
I have dropped a class from toolbox. While copying i selected the option as "Lifeline". For this newly added class, I am expecting el.type would give value as "LifeLine" but unfortunately it is giving "Object" only. Now my question is how this object can be identified as Lifeline of type Class?
Hope this gives more clarity.
If you drop a class onto a sequence diagram as a lifeline you will effectively get an element of type Object, that is an instance of your class.
Using the ClassifierID you can then get the Classifier element
So starting from you sample
Diagram sequenceDiagram = rep.GetDiagramByGuid(seqdiagGuid);
Collection<DiagramObject> diagObjs = sequenceDiagram.GetDiagramObjects();
for (DiagramObject obj : diagObjs) {
Element el = rep.GetElementByID(obj.GetElementID());
// How to differenciate whether this el is a lifeline?
String elementType = el.GetType(); //this will be "Object" if you drop a class as a lifeline, and "Sequence" if you choose a lifeline from the toolbox
if (el.GetClassifierID > 0) {
Element classifier = rep.GetElementByID(el.GetClassifierID);
}
}
I am building tests in SoapUI. I have a very large response (>3500 duties). For that response I need to build a request and execute that request. Currently the code (Java) works, but I would like to optimize the code.
For each Duty I build a request to get additional employee data and execute it using a for next loop. Below is an example of the large XML response that I get.
<DUTIES>
<DUTY>
<EMPNO>1</EMPNO>
<LOCATION>AMS</BASE_STATION>
<ACTUALTIME>2019-02-20T06:00:00</ACTUALTIME>
<POSITIONING_CODE>1</POSITIONING_CODE>
</DUTY>
<DUTY>
<EMPNO>2</EMPNO>
<LOCATION>RTM</BASE_STATION>
<ACTUALTIME>2019-02-20T06:00:00</ACTUALTIME>
<POSITIONING_CODE/>
</DUTY>
<DUTY>
<EMPNO>1</EMPNO>
<LOCATION>AMS</BASE_STATION>
<ACTUALTIME>2019-02-21T06:00:00</ACTUALTIME>
<POSITIONING_CODE>1</POSITIONING_CODE>
</DUTY>
</DUTIES>
As you can see from the sample the same employee is multiple times in the response, so currently I am calling the request multiple time for the same employee. I would like to optimize this.
In SoapUI I can use the statement:
String[] emps = resp.getNodeValues("/Duties/Duty/string(EMPNO)");
String[] locs = resp.getNodeValues("/Duties/Duty/string(LOCATION)");
String[] tims = resp.getNodeValues("/Duties/Duty/string(ACTUALTIME)");
Then I would like to sort the arrays on emps and only build a request to get additional employee data when the employee changes. This will make the code much faster.
Now my questions:
What is the best way to do this? Work with multidimensional array and sort them? Or is there a better way of doing this?
Thanks in advance,
Said
I would create an instance of java.util.HashMap<String,String> or java.util.HashMap<Long,String> depending on which datatype is returned, when you retrive the empno.
Just blindly do a map.put(empno,null) for each duty element, and you will only have each employee in the hashmap once afterwards, as each additional addition of the same key will overwrite the existing.
After that, simply
for (String key : map.keySet()) {
// do your stuff
}
As I see it, you really don't need to sort anything to get there.
I'm working with jQuery DataTables. I have it listing out a view and have checkboxes to select multiple documents. I'm able to get the selected keys into session scope via this client side JavaScript code :
<xp:this.script><![CDATA[// Build array of selected rows
var myTableApi = x$("inventoryTable").DataTable();
var count = myTableApi.rows( { selected: true } ).count();
var dataArr = [];
var rowData = myTableApi.rows( { selected: true } ).data();
$.each($(rowData),function(key,value){
dataArr.push(value[3]);
});
// Push that to the requestScope
setScopeValue("session", "rowCount", count);
setScopeValue("session", "rowIds", dataArr);]]></xp:this.script>
Once the id's are in Scope I change pages and then I want to load them into my Java pageController.
I can easily use a variable resolver to get ahold of "rowIds". But I'm not sure how to get it into Java so I could work with it. Ideally I'd like it to be List or Set or something similar.
In Java, how can I convert this JavaScript Array to a Collection based object?
Thanks!
There are a few tricks to do here.
First, since the particular implementation of your setScopeValue function converts all values to a string before sending them to the server, it's important to do setScopeValue("session", "rowIds", XSP.toJson(dataArr)). That way, the value stored on the server will be ["foo", "bar", "baz"] instead of foobarbaz.
Secondly, the best way to get to the session-scoped value in Java would be via ExtLibUtil.getSessionScope().get("rowIds").
That value will be a string, though, and not an array type, so it'll have to be parsed from JSON. Using the IBM Commons JSON capabilities, that can be done with:
List<?> rowIds = (List<?>)JsonParser.fromJson(JsonJavaFactory.instance, ExtLibUtil.getSessionScope().get("rowIds"))
for(Object rowIdObj : rowIds) {
String rowId = StringUtil.toString(rowIdObj);
// do stuff with each ID here
}
You can also potentially case it directly to a List<String>, since Java's generics are really just hints for compiler-generated code, and not really enforced in the objects themselves, but there you run the risk of a ClassCastException if the incoming List contains any non-string types.
I am new to apache olingo web service. I struck for the past two weeks to implement filter and pagination to my service.I am using latest olingo version 4. I google it and looked many blogs but there is no clear explanation. Kindly help me with sample code.It will be more use full for me.
Following are my scenario,
I am gettting the data from existing web service as XML and then i parse the XML using JAXB make it as list of entity in olingo web services.
Here how can i apply filter. If i having $filter in my URL means it throws page not found exception. If i remove that means it will work and give full result.
My question is How to apply olingo filter in XML string or
How to apply it in List of entity which i having it in a method.
Kindly give me the explenation with some sample code.
I need to give pagination to my response JSON.I need to limit the JSON value as 25 per page and need to next page URL also(For 25 to 50) like that.
How to implement this also.
I overcome lots of blogs but didn't work for me.
Here
https://templth.wordpress.com/2015/04/03/handling-odata-queries-with-elasticsearch/
In this blog,They didn't explain with full code.My problem is,I am getting data from existing web service as XML string and parse it and having in list of entity.
And I also refer this blog,
https://olingo.apache.org/doc/odata2/tutorials/Olingo_Tutorial_AdvancedRead_FilterVisitor.html
In this blog also they tell how to construct the query,My problem is how to implement $filter,$select etc from ODATA in my web service and how to filter from xml string or list of entity
Kindly suggest me with sample code.Thanks.
The Olingo team provides a huge amount of well organized help resources. The sample projects can be found by these instructions:
http://olingo.staging.apache.org/doc/odata4/tutorials/prerequisites/prerequisites.html#tutorial-sources
Complete tutorial about hte pagination can be found here:
https://olingo.apache.org/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html
I can also provide you the sample code. For example, if talking about the pagination, in your EntityCollectionProcessor implementation you just have to read the top and skip parameters and use them when generating a query to your existing web service using XML, JSON or whatever:
int skipNumber = 0;
SkipOption skipOption = uriInfo.getSkipOption();
if (skipOption != null) {
skipNumber = skipOption.getValue();
}
int topNumber = -1;
TopOption topOption = uriInfo.getTopOption();
if (topOption != null) {
topNumber = topOption.getValue();
}
EntityCollection responseEntityCollection = getDataFromService(edmEntitySet, skipNumber, topNumber);
Here the getDataFromService method generates a request to your services passing the top/skip parameters and retrieves the response. It is not advisable to filter the result set on the OData service side. Some additional steps you can find in the above mentioned tutorial.
Filtering is more complex but the main idea you can find from here:
https://olingo.apache.org/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html
I have a Backbone Model,Collection, and a server side REST implementation.
Can i send a request to the server that will replace the entire collection?
I tried doing this with jqeury.post request but I'm not sure what the data should hold (an array of items with the model attributes? an array of models? a collection?), and what should the REST recieves as parameters(A java List? a Java array? a custom object containing a list of something?).
Any thoughts of this issues? am i missing something
Thanks!
according with documentation, you need use fetch
documentation here [Backbone Fetch]: http://backbonejs.org/#Collection-fetch
fast example :
var newObject = new Object();
newObject.newvar1 = "newvar1"
newObject.newvar2 = "newvar2"
YOURMODEL.fetch({data: newObject,type:'POST'});