1
General Board / Re: SQL pivot
« on: February 18, 2016, 04:53:38 am »
Ho ho! Yeap, that's what I needed, perfect. Thanks Geert.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
SELECT o.Object_ID, o.Name, tag.Property, tag.Value
FROM (t_object o INNER JOIN t_objectproperties tag ON o.Object_ID = tag.Object_ID)
WHERE o.Stereotype = "Stakeholder"
AND tag.Property IN ("Class", "CurrentCommitment", "LevelOfInterest", "Power", "RequiredSupport")
Object_ID | Name | Property | Value |
123 | CEO | Class | High |
123 | CEO | Power | Keep Satisfied |
123 | CEO | LevelOfInterest | High |
124 | CIO | Class | High |
124 | CIO | Power | Keep Satisfied |
124 | CIO | LevelOfInterest | High |
Object_ID | Name | Class | Power | LevelOfInterest |
123 | CEO | High | Keep Satisfied | High |
124 | CIO | High | Keep Satisfied | High |
TRANSFORM First(tag.Value)
SELECT o.Object_ID, o.Name, tag.Property, tag.Value
FROM (t_object o INNER JOIN t_objectproperties tag ON o.Object_ID = tag.Object_ID)
WHERE o.Stereotype = "Stakeholder"
AND tag.Property IN ("Class", "CurrentCommitment", "LevelOfInterest", "Power", "RequiredSupport")
GROUP BY o.Object_ID, o.Name
PIVOT tag.Property
print("#stereotype#.emf");
image("#stereotype#.emf", 0, 0, 100, 100);
#!/bin/bash
function Error() {
printf "ERROR: $1.\n" 1>&2 && exit 1
}
[ -z "$1" ] && Error "Incorrect number of params."
[ ! -e "$1" ] && Error "Source file doesn't exist."
XPATHBASE="/MDG.Technology/UMLProfiles/UMLProfile/Content/Stereotypes/Stereotype"
TARGETDIR="${1%.xml}_ShapeScripts"
MTS=$(xmlstarlet sel -T -t -v "${XPATHBASE}/@metatype" $1)
[ -z "$MTS" ] && Error "No metatypes found in source file."
mkdir -p ${TARGETDIR}
for MT in ${MTS}
do
printf "\n\n=====================\nExtracting ShapeScript for metatype=${MT}\n"
xmlstarlet sel -t -v "${XPATHBASE}[@metatype='${MT}']/Image[1]" $1 | \
base64 -i -d | \
funzip | \
tr -d '\000' | \
tee ${TARGETDIR}/${MT}.ShapeScript
done
exit 0