Hi all,
I was able to figure it out eventually and here's the query I came up with (see below). It turns out that the AttCustom variable can be set to 0 or 1 and that flips the meaning of whether the attributes listed in the t_diagram.StyleEx column are hidden or shown. Sure would be great if Sparx would provide a document so users could figure out how to parse t_diagram.StyleEx and t_diagrambbjects.ObjectStyle. I never try to change the values there and wouldn't mind if they changed the rules, if they would just share the meaning of the stuff in there. Using the <Search Term> variable works sporadically at best for my semi-old copy of EA, so I've been substituting the actual diagram name before running the query. And we're going to have to figure out how to display the Description (notes fields) in a way that eliminates our newlines and commas (separate post). For what it's worth, here's the query - hope someone finds it useful:
SELECT
t_diagram.name AS [DIAGRAM NAME],
t_object.name AS [CLASS NAME],
t_attribute.name AS [ATTRIBUTE NAME],
t_attribute.type AS [DATA TYPE],
t_attribute.lowerbound+'..'+t_attribute.upperbound AS [CARDINALITY],
t_attribute.Notes AS [DESCRIPTION]
FROM ((t_diagramobjects
INNER JOIN t_object ON t_object.Object_ID = t_diagramobjects.Object_ID)
INNER JOIN t_diagram ON t_diagram.Diagram_ID = t_diagramobjects.Diagram_ID)
INNER JOIN t_attribute ON t_attribute.Object_ID = t_object.Object_ID
WHERE t_diagram.name = '<Search Term>'
AND t_object.Object_Type = 'Class'
AND (
(
(INSTR(t_diagram.StyleEx,MID(t_object.ea_guid,2,6)) = 0)
AND (INSTR(t_diagramobjects.ObjectStyle,'AttPro=0;AttPri=0;AttPub=0;AttPkg=0') = 0)
AND (INSTR(t_diagramobjects.ObjectStyle,'AttCustom=0') = 0)
AND "COMMENT: this set brings back attributes for classes where nothing is hidden."
)
OR (
(INSTR(t_diagramobjects.ObjectStyle,'AttPro=0;AttPri=0;AttPub=0;AttPkg=0') > 0)
AND (INSTR(t_diagram.StyleEx,MID('S_'+t_object.ea_guid,2,6)) > 0)
AND (INSTR(t_diagram.StyleEx,MID(t_attribute.ea_guid,2,6)) = 0)
AND "COMMENT: this set evaluates to false so that it excludes attributes for classes where all attributes are hidden."
)
OR (
(INSTR(t_diagram.StyleEx,MID(t_attribute.ea_guid,2,6)) = 0)
AND (INSTR(t_diagram.StyleEx,MID(t_object.ea_guid,2,6)) > 0)
AND (INSTR(t_diagramobjects.ObjectStyle,'AttCustom=0') > 0)
AND "COMMENT: this set shows unhidden attributes, whether hidden ones are selected individually or using the custom All button."
)
OR (
(INSTR(t_diagram.StyleEx,MID(t_attribute.ea_guid,2,6)) > 0)
AND (INSTR(t_diagram.StyleEx,MID(t_object.ea_guid,2,6)) > 0)
AND (INSTR(t_diagramobjects.ObjectStyle,'AttCustom=1') > 0)
AND "COMMENT: this set shows unhidden attributes, whether hidden ones are selected individually or using the custom All button."
)
)
UNION ALL
SELECT
t_diagram.name AS [DIAGRAM NAME],
t_object.name AS [CLASS NAME],
'' AS [ATTRIBUTE NAME],
'' AS [DATA TYPE],
'' AS [CARDINALITY],
t_object.Note AS [DESCRIPTION]
FROM ((t_diagramobjects
INNER JOIN t_object ON t_object.Object_ID = t_diagramobjects.Object_ID)
INNER JOIN t_diagram ON t_diagram.Diagram_ID = t_diagramobjects.Diagram_ID)
WHERE t_diagram.name = '<Search Term>'
AND t_object.Object_Type = 'Class'
ORDER BY 1, 2, 3;