How to display a PropertySheet on two columns - javafx

I need to display a Propertysheet (ControlFx) on two columns like this
property1 value1 property4 value4
property2 value2 property5 value5
property3 value3.
The first idea was to use two property sheets. But we don't like it. So we search a way to do it with only one property sheet.
Thanks for your help
I have this :
https://controlsfx.bitbucket.io/org/controlsfx/control/propertySheet.PNG
(I can't display image without 10 reputation...)
I want this :
https://preview.ibb.co/kmZq4z/One_Property_Sheet_Two_Columns.png

Related

Extracting JSON arrays and inserting them as separate rows in a new database

I have a database which uses JSON to store values.
CREATE TABLE JSON(name TEXT, value TEXT);
I am trying to convert this into a native format.
CREATE TABLE NATIVE(name TEXT, KEY1, KEY2, KEY3);
The JSON format looks like this:
[
{"key1":value1, "key2":value2, "key3":value3},
{"key1":value4, "key2":value5, "key3":value6},
....
]
For the above example, I am trying to come up with a query using INSERT INTO NATIVE (name, KEY1, KEY2, KEY3) SELECT <something> FROM JSON to produce this table:
+------+---------+--------+--------+
| TEXT | KEY1 | KEY2 | KEY3 |
+------+---------+--------+--------+
| TEXT | VALUE1 | VALUE2 | VALUE3 |
| TEXT | VALUE4 | VALUE5 | VALUE3 |
...
+------+---------+--------+--------+
I have been using JSON1 for other tables which use simple objects. So for instance when I have values which are objects and not arrays of objects I can use json_extract for each field.
For an array I think I am supposed to use json_each but I am having a hard time figuring out how to apply it to this specific problem.
I came up with this solution:
INSERT INTO NATIVE (name, key1, key2, key3)
SELECT name, json_extract(x.value, '$.key1')
, json_extract(x.value, '$.key2')
, json_extract(x.value, '$.key3')
FROM JSON, json_each(JSON.value) AS x;
The trick is that json_each when used in conjunction with the table containing JSON and a SELECT is returning rows in which there are fields called key and value which contain each key and value. It is then possible to call json_extract in the select to pick individual fields out, which can then be inserted into the new table.
We can try using the JSON_EXTRACT function from the json1 extension library, along with an INSERT INTO ... SELECT:
INSERT INTO NATIVE(name TEXT, KEY1, KEY2, KEY3)
SELECT
name,
JSON_EXTRACT(value, '$.key1'),
JSON_EXTRACT(value, '$.key2'),
JSON_EXTRACT(value, '$.key3')
FROM JSON;
This assumes that it is the value column in JSON which contains the raw JSON. If not, then replace value in the above query by whatever column contains the JSON content.

Symfony order by the content of a specific field

I want to sort data in repository based on the content of a specific field
For example i have an entity person with the fields role,fistName and lastName.
I would like to sort using ->orderBy('p.role', ???) and get a list ordered based on this order : professors then directors then teachers and at last students .
Example of my database:
Wanted result:
Ps: i can not use ASC or DESC since my sorting order is neither ASC nor DESC;
it is a custom order
Very strage scenario, you could use a CASE statement in order to assing a custom value for each fields then sort on him.
You could use the HIDDEN keyword.
As example take a look at this DQL:
SELECT p, CASE
WHEN p.role = "professor" THEN 1
WHEN p.role = "director" THEN 2
WHEN p.role = "teacher" THEN 3
WHEN p.role = "student" THEN 4
ELSE 99 END
AS HIDDEN mySortRule
FROM Bundle\Entity\Person p
ORDER BY mySortRule ASC
Hope this help

start with prior reference on last select

I have a problem while inserting based on select query
I have a schema in the database with a parent-child relationship that looks like the following
A
B
C
G
L
F
C
G
L
Notice how Element c is reused, because it´s aviable twice with different parent id, but element g is only aviable once, since the id of c is the same in both cases. The select prints everything as expected with the following query
select id,
parent_id,
label
from table
start with parent_id is null
connect by nocycle prior id = parent_id
order siblings by sort
i am having around 2500 elements in this table, but in the end around 4000 are displayed because a few elemnts should be displayed multiple times at different places.
So, to identify both, the first and second g as unique elements, i have written the following insert statement
insert into other_tale (id, parent_id, label)
select create_id new_id,
prior ???,
label,
from table
start with parent_id is null
connect by nocycle prior id = parent_id
order siblings by sort;
Here i am calling a procedure to generate a new id for each raw that has been found. Now i am stuck at the part where i do recieve the new id of the parent element. I know that i can refer to the prior parent_raw in the table beeing select, but am i able to somehow refer to the column new_id of the parent_element in the select?
Create a package with 1 associative array id_cache and 2 functions: f_clear_cache and f_generate_id.
f_clear_cache deletes the cached ids - id_cache.delete.
f_generate_id takes id as argument and returns the new_id
check if the new_id was already generated - id_cache.exists(id)
if not, generate the new_id and cache it - id_cache(id) := new_id
return new_id - return id_cache(id)
finally use the function in your sql statement
insert into other_tale (id, parent_id, label)
select my_package.f_generate_id(id),
my_package.f_generate_id(parent_id),
label
...
note: do not forget to call f_clear_cache when you want to generate new set of ids within the same session.

SQL update based on column in other table

Using SQLite, I am trying to update three columns based on another table (two columns)
The three columns are (Table1):
'AgentCreatedID'
'AgentOwnedID'
'AgentSentID'
The other table (Table2) consists of 'AgentID' and 'Designation'.
If the ID in one of the three columns matches the 'AgentID' in the second table, I want the 'Designation' value to populate. This table is a list of ALL unique IDs and the corresponding designation. Each row of data has a Creator, Owner, and Sender. I need to see what designation that person is from.
In Access, this would look something like this for the first value. I would also need to add the other two values.
UPDATE Table1
LEFT JOIN Table2 ON Table1.AgentCreatedID = Table2.AgentID
SET raw.AgentCreatedID = [ Table2 ]![ Designation];
I am not sure what that ! command is or how it could be used in SQLite.
SQLite does not suport joins in an UPDATE statement.
You have to look up the new value with correlated subqueries:
UPDATE Table1
SET AgentCreatedID = (SELECT Designation
FROM Table2
WHERE AgentID = AgentCreatedID),
AgentOwnedID = (SELECT Designation
FROM Table2
WHERE AgentID = AgentOwnedID),
AgentSentID = (SELECT Designation
FROM Table2
WHERE AgentID = AgentSentID)
The exclamation mark is used to separate the worksheet name from the reference in that worksheet. Here is Microsoft's explanation of cell references.
Now that you know what [ Table2 ]![Designatio] means, you can simplify it to use only the column name.

How to get XML value from a column in SQL Server

I have a SQL Server table tblApplications with some columns... one of the columns is called Content and has XML values like in the following Image:
when i clicked on the value of content in the above image it displays like following in new tab
I want to get the value using id from the xml value of dataitem that is under the datagroupItem of datagroup as selected in following image, using query from the tblApplications
How to get the value from the content using id?? E.g. I want to get the value of id of dataitem = 'ForeNames'
How to get it using query????
You could try this query:
SELECT a.application_id,
x.y.query('.') AS DataItemNode,
x.y.value('(#type)[1]','NVARCHAR(50)') AS TypeAttr,
x.y.value('(#value)[1]','NVARCHAR(50)') AS ValueAttr
FROM dbo.tblApplications a
CROSS APPLY a.Content.nodes('/XmlDataPairDocument/dataitem/datagroup/datagroupitem/dataitem[#id="forenames"]') x(y)
or
DECLARE #id NVARCHAR(50);
SET #id='forenames';
SELECT a.application_id,
x.y.query('.') AS DataItemNode,
x.y.value('(#type)[1]','NVARCHAR(50)') AS TypeAttr,
x.y.value('(#value)[1]','NVARCHAR(50)') AS ValueAttr
FROM dbo.tblApplications a
CROSS APPLY a.Content.nodes('/XmlDataPairDocument/dataitem/datagroup/datagroupitem/dataitem[#id = sql:variable("#id")]') x(y)
Another similar questions-answers: here #1, here #2

Resources