We are accessing Doors from an external .Net-program via DXL.
In that program we are currently getting all Objects linked to that Object through their modulname/absolute number from their links.
Now we have to neglect those, because we got an attribute grouping certain objects together (lets call it GroupID) and we need to link through GroupIDs saved in another attribute in our source object.
The actual question is, if theres any way to search objects for their certain attribute values?
I didnt find anything useful in the DXL documentation and the only way I can imagine right now, is iterating over the objects in a module an compare the attribute.
I don't know how you transfer the objects from DXL to .Net, if you use DXL scripts for preparing the objects and sending them, so this might not apply for you:
In DXL, you could use a filter (see chapter 25 "Display Control"→"Filters" in the DXL manual) and then use the "for Object in Module" loop that will traverse all filtered objects. But if I remember correctly, filters are internally implemented using something like a "for Object in entire Module" loop, so you might get the same speed using a manual iteration.
Related
In my project I have to parse JSON schema, that comes from server.
It has object "Properties", which in fact like Dictionary in curly braces. And, of course, JSONSerialization.jsonObject parses it as Dictionary.
Everything looks like OK, BUT: I use these Properties for building my view (it defines fields to be fiiled by user). Finally, I have to save order of these fields! But, as we know, immediately after the object is parsed to Dictionary, it looses keys order. Anybody knows how can I parse these object, saving fields order?
Additional information:
Structure of Properties is build by user in WEB, so their count is avsolutely random for mobile client. Furthermore, Every object in properties (e.g. Group) can have its own properties, containing other objects. So we have absolutely random tree of nested objects. And their order is necessary for us.
If you don't care about interoperability, meaning 3rd parties also being able to rely on order, you can try to find a parser that preserves order (such as by reading it into an OrderedMap in Python instead of a regular dict- obviously this will differ by language.)
If you care about 3rd parties, it's trickier. As the last person to respond noted, JSON itself does not support this, and JSON Schema is just JSON as far as parsing goes.
I need to pass near about 1000-1500 objects from one controller to another. My concern is basically on the speed. Will it affect if i send list or result. Or should i pass predicate and query it again. Then access the list of the queried object.
To be more clear.
I have object named Chat, which has a list of media. Now i wanna pass that media. What would be the best practice for that.
Also sometimes i need to filter the media. I then convert that result to list by using reduce func.
If you're referring to Realm Results objects, then you don't need to worry about this. Objects stored in Results are only lazily loaded into memory when your code specifically requests them. As such, passing the Results object around won't incur any overhead.
That being said, if you then use the native Swift reduce function to create a filtered array from a Results object, that would become a problem. That operation will go through and force each item in Results to get lazily-loaded at once, which could lead to memory issues. If possible, you should instead try and perform that operation using the Realm filter() method to produce another Results object.
There are at least 2 main collection types used in Realm:
List
Results
The relevant description from the documentation on a Results object says:
Results is an auto-updating container type in Realm returned from
object queries.
Because I want my UITableView to respond to any changes on the Realm Object Server, I really think I want my UITableView to be backed by a Results object. In fact, I think I would always want a Results object to back my UI for this reason. This is only reinforced by the description of a List object in the documentation:
List is the container type in Realm used to define to-many
relationships.
Sure seems like a List is focused on data modeling... So, being new to Realm and just reading the API, I'm thinking the answer is to use the Results object, but the tutorial (Step 5) uses the List object while the RealmExamples sample code uses Results.
What am I missing? Should I be using List objects to back my UITableViews? If so, what are the reasons?
Short answer: use a List if one already exists that closely matches what you want to display in your table view, otherwise use a Results.
If the data represented by a List that's already stored in your Realm corresponds to what you want to display in your table view, you should certainly use that to back it. Lists have an interesting property in that they are implicitly ordered, which can sometimes be helpful, like in the tutorial you linked to above, where a user can reorder tasks.
Results contain the results of a query in Realm. Running this query typically has a higher runtime overhead than accessing a List, by how much depends on the complexity of the query and the number of items in the Realm.
That being said, mutating a List has performance implications too since it's writing to the file in an atomic fashion. So if this is something that will be changing frequently, a Results is likely a better fit.
You should use Results<> as the Results is auto updating to back your UITableView. List can be used to link child models in a Realm model. where as Results is used to query the Realm Objects and you should add a Realm Notification Token so you know when the Results are updated and take necessary action (reload table view etc.) Look here for realm notifications: https://realm.io/docs/swift/latest/#notifications
P.S. The data in that example is just static and no changes are observed
I hope this isn't an inappropriate post, but I wanted to make sure my first steps implementing parse as my backend are in the right direction to save some time. I'm new to both iOS programming and the parse sdk, so please bear with me!
In my app, users are able to create various polygon shape overlays on a Google Maps mapView, stored as a GMSMutablePath, which is basically a list of coordinates. Users will have at least one group of paths, each with at least one path. There will also be some information stored with each group, stored as strings or numbers. This information is specific to a single group of paths.
I'm trying to figure out the best way to store this data. My first basic question is 1) Can I store the GMSMutablePath as a whole in the Object data type? Or does the Object data type refer to a class that is created through parse? This link (https://www.parse.com/questions/what-is-data-type-of-object-in-data-browser) is the 'best' explanation I found of the Object data type, and it isn't very clear to me.
My gut instinct is no, I can't store the GMSMutablePath object, and that Object refers to a Parse object. Which leads me to 2) How should I store this data, then? I can get the individual lat/long values of the coordinates that make up each path, and I can store those as numbers, and use the numbers to recreate the paths elsewhere. None of the paths should use too many coordinates, and there shouldn't be too many paths in each group.
Playing around a little bit in the data browser, I see that I can store arrays, but I'm not sure how those are formatted, as I'd need an array (of groups) of arrays (of paths) of arrays (of lat/long values). A little bit of googling tells me it can be done, but doesn't show me how. Can any datatype be stored in any array, or is a datatype specified? I'm used to C++ programming, so I'm used to an array containing a single type of element. What I'm thinking is that I'd need an array of objects, which would be the groups of paths. Each one of those objects would have the string/number information associated with the group, as well as an array for the paths within the group. For each one of those paths, it would have to be either an array or an object. Since for the path I just need the coordinate lat/long values, I think that I can get away with an each path being an array of numbers, and I can write my program to use one array, with odd indexes being lat / even indexes being long values. That all being said, I'm not sure how to create all of that. I'm not looking for somebody to write my implementation for me, but all of the examples I can find are much more simple... if anybody could point me in the right direction to do this, or has a better idea of how to do it, I'd love some pointers.
Each user is going to have their own groups, but that data is going to be shared with others at some point. The data will be associated with the user it belongs to. With that in mind, my last question is 3) Should I store all of this information specific to a user and their groups on the User class, or make it all a separate class entirely? My guess it that I should add an Object to the User class, and store the groups within that Object. I just want to make sure I have that right, with future scalability in mind. Like, when I pull the group data, am I going to have to pull the entire User data from another user, and if so, is that going to slow things down significantly? I'm thinking that I do have to send entire user data, but I don't know if that poses any security risks. Would it be best to have a separate class for the groups, and store the user id associated with the groups? If I do this, should I also store the groups as an object on the User class?
Sorry for the wall of text, but thank you for any guidance you can provide!
If you need any clarification, let me know.
Thanks,
Jake
Creating a class to hold all the objects turned out to be unnecessary. It only had a few extra details that were just as convenient to add to the user object, and then have an array of objects on the user.
Some main things to note that I learned are: use addObject to add to an array, rather than setObject to add a single object to a PFObject/User.
Parse fetching/saving happens in background threads, so if you're loading the data to do something specific with it, make sure the code using the data occurs inside a block using the [PFObject fetchInBackgroundWithBlock] method.
Also, as changes are made to the structure of your data on a parse user/object, make sure you sign out of the current user and create a new one on your app, or you may run into lots of undefined behaviour that could crash your app.
i want to get specific element in a Set in JSF 2
please advise how to do that.
This problem is not specific to JSF/EL. Already in plain Java you cannot access a specific element in a Set. The Set has no method like get(index) as the List has. You need to convert the Set<T> to a T[] array or a List<T> so that you can access it by an index.
This works in a predictable way for SortedSet or LinkedHashSet only as the elements are then inserted in respectively the sorted order or insertion order. This would not make any sense when it's a HashSet as you cannot reliably predict beforehand at which index the element would end up.
If you're using EL 2.2 (your question history confirms this), then you can just use Set#toArray() to convert it to an array and then use the brace notation [] to access the element by index. The below example prints the second item of the array representation of the #{bean.someSet}.
#{bean.someSet.toArray()[1]}
Again, this makes no sense if it's an unordered set like HashSet.
Your problem is quite unclear, but JSF2 doesn't really support Set.
Components like ui:repeat or h:datatable always need a sort to display data, so your best choice will be to convert your Set to a List first.