Jan Kaczmarek

Ranch Hand
+ Follow
since May 02, 2020
Jan likes ...
IntelliJ IDE MySQL Database Java
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jan Kaczmarek

For the ancestors! I love my life FIXED! Now just optimization.
I was overwriting the root all the time. In addition, the process of searching for descendants was not assigned to anything. It was searching for searching.

1 month ago
Debugging result. Here is a problem, but I have got no idea how to fix it.
1 month ago
Another change : Now it returns only last children's of one root, thats all
1 month ago
So after few hours of tests, coding and thinking "i hate data tree structures" I created something like this:

So I decided to use Org model anyway.
Eveything should work but hm... Its not looking for childrens and I have got no idea why
1 month ago
Unfortunately - I have to use OranizationSubtree and OrganizationTree, I have these two in the requirements and I can't change it, so I have to adapt your solution somehow. Version with entity "Organization" is completely eliminated.
It seems to me a big problem that the way to store data is an array. By adding another node I will have to copy the array each time and create a new one, larger by one
1 month ago
I inspected whole documentation and I saw that Im forced to use 2 types of objects :


Does it change a lot?
It seems to me the way to solve this:
1) I am creating a POJO that will look like Organization
String id;
String name;
String parentId;
and save them in HashMap <String [id], Organization>
2) Creates an OrganizationTree object and initializes an empty array in it with a length equal to the number of objects marked as "root"
2) I drop all root objects into OrganizationTree (previously changed their type to OrganizationSubtree) and remove them from the map.
3) I iterate around the map taking the first objects that point to root as the parent object from the map and removing them from the map and putting them in the parent table.
4) I iterate across the map like this until it's empty.
It seems to me the simplest, but also terrible in terms of efficiency. Every time I will have to search every object and every array in it and in every array - another object with arrays (it is not known how many layers, there can be hundreds) + every time i add another children I need to create new array and copy the old one - because at the beginning i dont know how many childrens may parent have
1 month ago
So here I'm once again...
I've got this data model saved in my in memory database H2:

Examples of objects in repository:  

And this database contains almost 10 k records like that.  
I need to get all this data out, create tree from them (i literally have got no idea how-after few guides-still empty) and send it to frontend in one JSON.  
Desired JSON example:

It looks like this JSON answer is an array (Im not sure about it)
Any idea how to start? How should it look like step by step? I am sitting and unfortunately I cannot get to it. I am looking for a simple and clear solution. I will work on performance after I make the first working version (if I can do it at all).
Main problem for me that I have got X roots- I've got no idea how to make tree that have got many entry points
Thanks in advance for any help!
1 month ago

Rob Spoor wrote:You can use a library like opencsv or Apache Commons CSV to parse the contents. I think you can even use Jackson with jackson-dataformat-csv to parse it directly to objects.

Whatever you do, don't parse the contents yourself. CSV may look simple, but you may get unexpected results if the CSV becomes a bit more advanced (like including quotes around string values).

The problem is that these libraries work on CSV files - I get it in the form of one String on the server side, so I probably have to choose the form
2 months ago
So the method accepting such a request will look like this :

because this request actually accepts a CSV file, but passes all its contents to me on the server side in the form of a String, am I right?
After this PUT I will have argument, that looks like:

2 months ago
This swagger is just representing my API endpoint documentation (this is the PUT part of it).
CSV example (the one I made for tests)


I cannot edit the request. I have to conform to it. The whole problem is with this part:
2 months ago
I am trying to write a method that will respond to this http request. Unfortunately, I do not know what the argument of such a method should be.


At first I thought it would be a Multipartfile and then I would just process it (see dummy approach below), but then I saw a "string" in swagger and it confused me a bit. I have no clue anymore what the format of the input data is.
(I know- I should use nio, no io)

2 months ago
Thank you for your answer. So I tried several approaches with this advice.

Version no.1 (this one looks better)

Version no.2

In browser when I login it redirects me me to the blank page instead of calling login form again-so I think this means that everything is ok with both methods.
When I try to send credentials using postman- app throwing me InternalAuthenticationServiceException in authenticate method (in both versions). And Im not sure right now if it is lack of experience and basic knowledge about postman or still something is wrong with this code.
Thank you for review!
Best regards
5 months ago

5 months ago

5 months ago
5 months ago