JaVers why is getPropertyChanges returning a List? - javers

The title really says it all. Curious as to how its possible to have a scenario where a property can end up with multiple change entries.

According to the JavaDoc for Changes, it is a:
Convenient wrapper for the list of Changes returned by {#link Javers#findChanges(JqlQuery)}.
So any property that could change more than once over the lifespan of an Entity could result in multiple entries in the getPropertyChanges list.
For example: You have an inventory tracking system that updates the number of each item in stock (using a property called "numberAvailable") each time someone buys something. One day, five different people purchase the "Blue Pen" item. At the end of that day, you call Javers#findChanges using a query that gives you all changes for the "Blue Pen" item from the past 24 hours. That gives you a Changes object that contains five changes (one for each purchase event). Each of those changes is to the "numberAvailable" property, so if you call getPropertyChanges("numberAvailable") then you end up with a list that contains all of those five changes.

Related

In NetSuite, can I sort a transaction by item # or some other column field?

Is it possible to sort the lines in a transaction by item (or some other column field)? We often receive very large orders from our customers and the items are in a more or less random order. When we receive said items from our vendors, the items come in numerical order by part number. It's very difficult for our logistics to receive them when our purchase order is in random order but the items came numerically. Is there any way for me to sort the purchase order by item #?
Re-sorting transaction lines is possible but quite prone to breaking. Until Netsuite actually supports it my recommendation would be to not spend time trying to re-sort lines.
About the only place it's safe to do that is on a Sales Order in the before Submit phase. Generally a sales order is the start of a whole chain of related transactions. Some of these relations are visible from fields and some are hidden. There is no api to re-sort the lines so the the way to get them sorted is to cache the lines in memory; clear the lines from the sales order; and then re-insert the lines in the desired order.
You have to make sure you capture everything and that you account for future customizations in your code.
So the alternative of supplying a sorted UI to aid fulfillments and receipts is much more reliable. Some of the ways I've done that include:
Adding a text area where people can paste a formatted list of skus/qtys received. A client script processes that and sets up the item receipt lines.
Creating a pop-up with the PO's items sorted as you like with whatever controls you need for efficient handling. The pop-up has a button for processing items when you are done with the receipt.
A field that lets you enter a sku (can have type ahead) that either brings you to the item you are receiving (selects the line) or provides a qty field as well so you just work at the top of the item list and enter and sku/qty/click process... until you have received the order
a similar thing but expecting a scanner to provide the sku so the process is gun/qty/click process

How to properly read all changed entities from external API

I need to properly traverse over all items in some external API. All items have "update_time" property and I can query the items from API in ascending or descending order. Which I should use to properly get all items without missing any of them?
Facts:
External API has pagination (limit and page parameters are fixed) and I cannot query all items by one query.
Querying of items takes some time.
Processing of received items takes some time.
While a page of items is queried or processed, items in external system can be changed -> this cause updating its 'update_time' property and influence ordering (paginating), so next page API call can cause "gap" in list of received items.
I don't want to process all items every time - only updated ones by the last traverse (this task is scheduled every 1 hour for example) - I store max of "last_update" property of all received items and skip processing of older items next traverse.
Thanks, it's really complicated to imagine for me.

Count how many times one post has been read

Is it possible to show how many times one post has been read? In WordPress there is a plug-in,https://wordpress.org/plugins/wp-postviews/
I don't know whether there is such a plug-in in Anypic of Parse to count the times?
Of course it will be nice if it can display who has read a post as well.
Thanks
I'm not sure which language you working on.
But anyway you need to create:
Array column in Parse.com
And then just make query to add his name when viewWillAppear
Now you can count the array to get integer number for views and you can display their names from the array.
Two options are;
Add a viewcount column and increment it whenever needed.
Add an actions table which consist all actions within your webpage or app. This way you can store more data(custom analytics) in it like button pressing etc.. When you want to check the viewcount you can just count objects with specific type. For iOS SDK countObjectsInBackgroundWithBlock does this job.

Efficient way to query

My app has a class that saves picture that users upload. Each object in the class has a city property that holds the name of the city that the picture was taken at, and a like property that tracks the number of likes.
I want to be able to send a query that returns one picture per city and each picture should have the highest ranking of likes in the city it belongs to. How can I do that?
One way which I first thought about is doing multiple queries by fetching the most liked picture of a city and save it in an array, and then do the same to other cities.
However, each country has more than one city, thus it's not that efficient.
Parse doesn't support the ordinary operations used in databases. Besides, I tried to use a compound query. Unfortunately, I can't set limit or ordering on the subqueries. Any good solution for this?
It would be easy using group by. Unfortunately, Parse does not support "select distinct" or "group by" features.
As you've suggested you need to fetch for each country all the cities, and for each one get the top most rated photo.
BUT, since Parse has strict restrictions on the duration time execution of a request ( 3 sec for an event listener, 7 sec for a custom function ), I suggest you to do this in a background job, saving in a new table the top rated photo for each city. In this way you can easily query the db from client. The Background jobs can be executed up to 15 minuted before parse drop them, so you could make that kind of queries without timeouts.
Hope it helps

WCF Data Services - neither .Expand or .LoadProperty seems to do what I need

I am building a school management app where they track student tardiness and absences. I've got three entities to help me in this. A Students entity (first name, last name, ID, etc.); a SystemAbsenceTypes entity with SystemAbsenceTypeID values for Late, Absent-with-Reason, Absent-without-Reason; and a cross-reference table called StudentAbsences (matching the student IDs with the absence-type ID, plus a date, and a Notes field).
What I want to do is query my entities for a given student, and then add up the number of each kind of Absence, for a given date range. I prepare my currentStudent object without a problem, then I do this...
Me.Data.LoadProperty(currentStudent, "StudentAbsences") 'Loads the cross-ref data
lblDaysLate.Text = (From ab In currentStudent.StudentAbsences Where ab.SystemAbsenceTypes.SystemAbsenceTypeID = Common.enuStudentAbsenceTypes.Late).Count.ToString
...and this second line fails, complaining "Object reference not set to an instance of an object."
I presume the problem is that while it DOES see that there are (let's say) four absences for the currentStudent (ie, currentStudent.StudentAbsences.Count = 4) -- it can't yet "peer into" each one of the absences to look at its type. In fact, each of the four StudentAbsence objects has a property called SystemAbsenceType, which then finally has the SystemAbsenceTypeID.
How do I use .Expand or .LoadProperty to make this happen? Do I need to blindly loop through all these collections, firing off .LoadProperty on everything before I can do my query?
Is there some other technique?
When you load the student, try expanding the related properties.
var currentStudent = context.Students.Expand("StudentAbsences")
.Expand("StudentAbsences/SystemAbsenceTypes")
.Where(....).First();

Resources