Convert Enterprise architect sequence diagram to Visio - visio

I have created 15 sequence diagrams using Sparx Enterprise Architect. My client wants these diagrams in Visio only. Is there any tool to convert already created EA diagrams to Visio?

If your EA instance is on MS SQL Server you can export the shape data from Sparx EA and then import to Visio using the data visualizer (Excel import)
Query to extract:
--Create temp table of Swimlanes
WITH t_object_CTE (Object_ID, Swimlane)
AS (SELECT t_object.Object_ID,
Name
FROM t_object
WHERE Stereotype = 'Pool')
SELECT
do.Object_ID,
o.Name AS ProcessStep,
o.Object_Type,
o.Stereotype AS ShapeType,
do.Sequence,
STRING_AGG(COALESCE(CAST(c.End_Object_ID AS varchar),''), ',') AS NextProcessStep, --concat across rows and replace NULL with empty string
s.Swimlane,
o.Phase
FROM [SPARX].[dbo].[t_diagram] AS d
JOIN t_diagramobjects AS do ON d.Diagram_ID = do.Diagram_ID
JOIN t_object AS o ON do.Object_ID = o.Object_ID
JOIN t_object_CTE AS s ON o.ParentID = s.Object_ID -- join to temp table
LEFT JOIN t_connector AS c ON o.Object_ID = c.Start_Object_ID
WHERE d.NAME LIKE '%EA Prepayment%'
GROUP BY do.Object_ID,
o.Name,
o.Object_Type,
o.Stereotype,
do.Sequence,
s.Swimlane,
o.Phase
ORDER BY do.Sequence DESC
SELECT StereoType,
COUNT(StereoType) as 'Count'
FROM t_object
GROUP BY Stereotype
ORDER BY 'Count' DESC
Visio Data Visualizer
https://www.microsoft.com/en-us/microsoft-365/blog/2017/05/01/automatically-create-process-diagrams-in-visio-from-excel-data/
For a deeper understanding of Database Structure recommend buying Inside Enterprise Architect, Querying EA's Database by Thomas Kilian. Its an excellent resource for understanding the table structure.
https://leanpub.com/InsideEA

Related

Postgres SQL query group by get most recent record instead of an aggregate

This is a current postgres query I have:
sql = """
SELECT
vms.campaign_id,
avg(vms.open_rate_uplift) as open_rate_average,
avg(vms.click_rate_uplift) as click_rate_average,
avg(vms.conversion_rate_uplift) as conversion_rate_average,
avg(cms.incremental_opens),
avg(cms.incremental_clicks),
avg(cms.incremental_conversions)
FROM
experiments.variant_metric_snapshot vms
INNER JOIN experiments.campaign_metric_snapshot cms ON vms.campaign_id = cms.campaign_id
WHERE
vms.campaign_id IN %(campaign_ids)s
GROUP BY
vms.campaign_id
"""
whereby I get the average incremental_opens, incremental_clicks, and incremental_conversions per campaign group from the cms table. However, instead of the average, I want the most recent values for the 3 fields. See the cms table screenshot below - I want the values from the record with the greatest (i.e. most recent) event_id (instead of an average for all records) for a given group).
How can I do this? Thanks
It sounds like you want a lateral join.
FROM
experiments.variant_metric_snapshot vms
CROSS JOIN LATERAL (select * from experiments.campaign_metric_snapshot cms where vms.campaign_id = cms.campaign_id order by event_id desc LIMIT 1) cms
WHERE...
If you are after a quick and dirty solution you can use array_agg function with minimal change to your query.
SELECT
vms.campaign_id,
avg(vms.open_rate_uplift) as open_rate_average,
avg(vms.click_rate_uplift) as click_rate_average,
avg(vms.conversion_rate_uplift) as conversion_rate_average,
(array_agg(cms.incremental_opens ORDER BY cms.event_id DESC))[1] AS incremental_opens,
..
FROM
experiments.variant_metric_snapshot vms
INNER JOIN experiments.campaign_metric_snapshot cms ON vms.campaign_id = cms.campaign_id
WHERE
vms.campaign_id IN %(campaign_ids)s
GROUP BY
vms.campaign_id;

How to effiecently union multiple 3d polygones and cast them to another table?

I am working with a large amount of CityGML 3d building data (LoD2) and imported the data using the 3D City Database (and its Importer/Exporter tool) (see https://www.3dcitydb.org/3dcitydb/) which creates a new schema in the database and uses java routines to translate the XML-style geodata to PostGIS compatible database input.
The information (spatial and non spatial) for each building is then written to different tables, where "building" table holds building meta data such as building function or street name and "surface_geometry" table holds solid and 3d surface geometries of all buildings. With columns "id", "parent_id" and "root_id" used as PKs and FKs to ensure the elements of one table can be matched to one or more elements of the other table.
Since I need 2d building footprints (or bird view polygones) for most of my analyses, I created queries to make surfaces 2d with st_force2d() before st_union()ing all 2d surface of the same building with group by on the available FK.
Are there any ideas how to improve the following code to effiecntly process a huge dataset?
The queries are
CREATE TABLE citydb.building_geom_tmp AS
SELECT a.*, b.bldg_footprint AS geom
FROM Citydb.building AS a
LEFT JOIN (
SELECT *, ST_Force2D(geometry) AS bldg_footprint FROM citydb.surface_geometry
) AS b
ON a.lod2_solid_id = b.root_id;
DROP TABLE IF EXISTS citydb.building_geom ;
CREATE TABLE citydb.building_geom AS
SELECT a.*, b.geom
FROM citydb.building AS a
LEFT JOIN (
SELECT id, ST_Union(geom) AS geom
FROM citydb.building_geom_tmp AS c
GROUP BY c.id
) AS b
ON a.id = b.id;
DROP TABLE IF EXISTS citydb.building_geom_tmp
I am working on a VM with Win 10 and
SELECT version() and SELECT postgis_full_version() give
PostgreSQL 13.2, compiled by Visual C++ build 1914, 64-bit
and
POSTGIS="3.1.1 3.1.1" [EXTENSION] PGSQL="130" GEOS="3.9.1-CAPI-1.14.1"
PROJ="7.1.1" GDAL="GDAL 3.2.1, released 2020/12/29" LIBXML="2.9.9"
LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" RASTER
respectively.
The 3dcityDB is 4.1.0 on the virtual machine with postgres/postgis-versions shown above.
Sample CityGML LoD2 data could be downloaded from the German Federal Agency for Cartography and Geodesy (here).
In addition I asked the 3DCityDB developers for ideas in ther github repo here.
Thanks in advance for any ideas and best regards
André
Got an answer from the developers directly on Github:
https://github.com/3dcitydb/3dcitydb/issues/73

Using UNNEST in a custom Postres Query in Google Data Studio

I have a table that has multiple values saved in an array in one column. (I know that this is not normalized/optimal database structure.) I'm trying to write a query that can create rows for each value in the array. The query below is working for me in Tableau but not Google Data Studio (I'm using a custom query with the PostgreSQL connector). Are there any limitations/different syntax requirements when using UNNEST in Data Studio?
SELECT
e.name as event_name,
e.date as event_date,
l.full_name as leader_name,
p.full_name as participant_name
FROM
(
SELECT
event_id,
user_id,
UNNEST(participants_ids)::INTEGER as participant_id
from event_reports
) r
LEFT JOIN events e ON r.event_id = e.id
LEFT JOIN users l ON r.user_id = l.id
LEFT JOIN users p ON r.participant_id = p.id
Your inner query should probably have a lateral join:
SELECT e.event_id,
e.user_id,
p.participant_id
FROM event_reports AS e
CROSS JOIN
LATERAL unnest(e.participants_ids) AS p(as participant_id)
With a lateral join, you can reference something from the left side of the join on the right side. The cross join combines each event_reports row with rach participant ID that belongs to that row.

SQL Tables with no direct relation

I have a PostgreSQL DB and I need to build a query to retrieve the information from a table that has no direct link with the main one.
The client is linked to the client_identity_document through its UUID and client_identity_document to the identity_document through the uuid_identity_document. I know I have to make an inner join, but I just started with relational databases and I don't know exactly the syntax to join tables that don't have direct relation.
try this
select *
from client c
inner join client_identity_document cid on c.UUID = cid.UUID_Client
inner join identity_document id on cid.uuid_identity_document = id.UUID

SQL Server 2008: many to many tables with relational tables ordering field + grouping

To understand what I need, here is the table's I'm using diagram: http://pascalc.nougen.com/stuffs/diagram.png
I need to get a project's properties + all it's relation, all listed based on the corresponding relational tables' OrderNumber column.
Let's say I need "Project Z", I want to get:
Project's BaseUrl, ... where ID = #ID
All testsuites associated to that project, listed by ProjectsToTestSuites.OrderNumber
All testcases associated to the matching testsuites, listed by TestSuitesToTestCases.OrderNumber
All testaction associated to the matching testcases, listed by TestCasesToTestActions.OrderNumber
So far, all my attempts are returning back results with mixed ordering. A testcase is mixed inside a testsuite it doesn't belong to and alike.
I try to avoid using cursors (loop each relation in specific order required), tried the use of UNION but couldn't get it to work either.
I wouldn't have troubles with cursor but if a solution exists withuout the need to use it, I prefer of course.
Thanks
If you want a flat result you could start with something like this (untested)
select
p.Id,
p.BaseUrl,
ts.*,
tc.*,
ta.*,
pts.OrderNumber as SuitesOrder,
tstc.OrderNumber as CasesOrder,
tcta.OrderNumber as ActionsOrder
from
Projects p
join
ProjectToTestSuites pts
on pts.Projects_Id = p.Id
join
TestSuites ts
on ts.Id = pts.TestSuites_Id
join
TestSuitesToTestCases tstc
on tstc.TestSuites_Id = ts.Id
join
TestCases tc
on tc.Id = tstc.TestCases_Id
join
TestCasesToTestActions tcta
on tcta.TestCases_Id = tc.Id
join
TestActions ta
on ta.Id = tcta.TestActions_Id
where
p.Id = #Id
order by
pts.OrderNumber,
tstc.OrderNumber,
tcta.OrderNumber