Geoserver style with condition - styles

How can I use a different image (OnlineResource) depending on the attribute value?
I have a feature with a 'number' attribute, I need to do something like:
if number = 0 then OnlineResource = image 1
else OnlineResource = image 2

you can try creating a rule with the tag (empty) instead of the ogc:Filter ... </ogc:Filter> tag
An else rule applies when, after scale and filters are applied, no other rule applies.
<FeatureTypeStyle>
<Rule>
<Name>local-road</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>number</ogc:PropertyName>
<ogc:Literal>0</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
...
</Graphic>
</PointSymbolizer>
</Rule>
<!-- this is the else rule -->
<Rule>
<Name>else</Name>
<ElseFilter></ElseFilter>
<PointSymbolizer>
<Graphic>
...
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>

You can use two rules with filters in your SLD:
<FeatureTypeStyle>
<Rule>
<Name>local-road</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>local-road</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#009933</CssParameter>
<CssParameter name="stroke-width">2</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
<Rule>
<Name>secondary</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>secondary</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#0055CC</CssParameter>
<CssParameter name="stroke-width">3</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>

Related

Parsing XML for sub children using using python

I am trying to parse the below XML to get the following data. There are multiple rules following, I have shared only one rule below. Is it possible to parse the XML for these values?
name from section header, rule id value, applied-to name, source names, source values, destination name, destination value.
<?xml version="1.0" encoding="UTF-8"?>
<filteredfirewallConfiguration timestamp="1621338984151">
<contextId>globalroot</contextId>
<layer3Sections>
<section id="asdfsdf" name="production" generationNumber="132" timestamp="1621930404081" managedBy="universalroot-0" tcpStrict="false" stateless="false" useSid="false" type="LAYER3">
<rule id="1213213" disabled="false" logged="true" managedBy="universalroot-0">
<name>From Conversion Server</name>
<action>allow</action>
<appliedToList>
<appliedTo>
<name>re-int-dx</name>
<value>universalwire</value>
<type>VirtualWire</type>
<isValid>true</isValid>
</appliedTo>
<appliedTo>
<name>re-ext-ap</name>
<value>universalwire</value>
<type>VirtualWire</type>
<isValid>true</isValid>
</appliedTo>
</appliedToList>
<sectionId>sfsdfafee</sectionId>
<sources excluded="false">
<source>
<name>sdfsdf101</name>
<value>ipset-werfwefdc</value>
<type>IPSet</type>
<isValid>true</isValid>
</source>
<source>
<name>sdfsfdf102</name>
<value>ipset-4wsetgfreds</value>
<type>IPSet</type>
<isValid>true</isValid>
</source>
</sources>
<destinations excluded="false">
<destination>
<name>production-database-cluster</name>
<value>sg</value>
<type>SecurityGroup</type>
<isValid>true</isValid>
</destination>
<destination>
<name>newname</name>
<value></value>
<type>IPSet</type>
<isValid>true</isValid>
</destination>
</destinations>
<services>
<service>
<name>servicenwe</name>
<value>application-dgfsdfg</value>
<type>Application</type>
<isValid>true</isValid>
</service>
</services>
<direction>inout</direction>
<packetType>any</packetType>
</rule>
sofar, I have been able to get the section header only.
import requests
import xml.etree.ElementTree as ET
tree = ET.parse("out.xml")
root = tree.getroot()
for child in root.find('./layer3Sections'):
print(child.tag, child.attrib)

Powershell command -- To add a attribute if not exist in a particular node of a XML

<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0">
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true">
my file has many line begining with word "add name".
I want to check if these lines have a string "managedRuntimeVersion".
if not exists, then i need to add managedRuntimeVersion="v2.0" to
that line.
Expected Result as below
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0">
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true" managedRuntimeVersion="v2.0">
I have tried with the below script.. but in the result.. it is given only the lines having "add name"
$sfile="C:\Users\subash.s\Desktop\backup\pool.xml"
(((gc "$sfile") | Select-String -Pattern "add name" |
select-string -notmatch "managedRuntimeVersion") -replace '>',' managedRuntimeVersion="v2.0">') |
Set-Content "$sfile"
with the above script. i got below result..
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0">
<add name="GetServiceDet" autoStart="true" managedRuntimeVersion="v2.0">
For Pete's sake, the configuration file is XML, not a text file! Edit it as an XML document, and you will save a lot of headaches.
There are a few ways to add attributes into such a document. As the XML in the question is a fragment - and of illegal syntax, the sample code uses a bit modified version of the same. Select all add nodes that don't have got managedRuntimeVersion attribute, create one and add attribute with values to the nodes. Like so,
# Dummy data for testing
[xml]$x = #'
<root>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet2" autoStart="true"/>
</APPPOOL>
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0" />
</APPPOOL>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true"/>
</APPPOOL>
</root>
'#
# Select all add elements that don't have managedRuntimeVersion attribute
$nl=$x.SelectNodes('/root/APPPOOL/add[not(#managedRuntimeVersion)]')
# Add attributes to the elements
foreach($n in $nl) {
# Create new attribute and assign a value
$a = $x.CreateAttribute('managedRuntimeVersion')
$a.Value = 'v2.0'
[void]$n.Attributes.Append($a)
}
# Print modified version to console
$x.save([console]::out)
# Output
<?xml version="1.0" encoding="ibm850"?>
<root>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet2" autoStart="true" />
</APPPOOL>
<APPPOOL APPPOOL.NAME="Classic" RuntimeVersion="v2.0" state="Started">
<add name="Classic" autoStart="true" managedRuntimeVersion="v2.0" />
</APPPOOL>
<APPPOOL APPPOOL.NAME="GetServiceDet" RuntimeVersion="v2.0" state="Started">
<add name="GetServiceDet" autoStart="true" managedRuntimeVersion="v2.0" />
</APPPOOL>
</root>
Reading the actual file and saving changes to disk are left as an exercise to the reader.

Routing to a different channels based on condition

I would like to route the message to different channels based on the condition of the property.
Let's say I have score property. If the score is <100 then it goes to "perfectchannel" else it goes to "normalchannel"
Where do I specify the spel expression or condition
<si:router id="serviceRouter" input-channel="serviceRoutingChannel"
expression="payload.score" default-output-channel="badchannel"
resolution-required="false">
<si:mapping value="100" channel="perfectchannel" />
<si:mapping value="<100 ??" channel="normalchannel" />
</si:router>
Appreciate your help on this.
We have a JIRA ticket on the matter, but haven't come up with the solution yet.
Right now you can achieve this behaviour with condition from the expression and providing mapping for true and false and with cascad of the routers:
<si:router id="serviceRouter" input-channel="serviceRoutingChannel"
expression="payload.score == 100">
<si:mapping value="true" channel="perfectChannel" />
<si:mapping value="false" channel="nestedRouterChannel" />
</si:router>
<si:router input-channel="nestedRouterChannel"
expression="payload.score lt 100">
<si:mapping value="true" channel="normalChannel" />
<si:mapping value="false" channel="badChannel" />
</si:router>
UPDATE
Another option to use <recipient-list-router>:
<recipient-list-router id="serviceRouter" input-channel="serviceRoutingChannel">
<recipient selector-expression="payload.score == 100" channel="perfectchannel"/>
<recipient selector-expression="payload.score lt 100" channel="normalchannel"/>
<recipient selector-expression="payload.score gt 100" channel="badchannel"/>
</recipient-list-router>

add icon instead of label in link

I'd written this code:
<action method="addLink" translate="label title" module="checkout">
<label>Cart</label>
<url helper="checkout/url/getCartUrl"/>
<title>Cart</title>
<prepare/>
<urlParams/>
<position>150</position>
</action>
But instead of the label Cart I want to show an image. How could I add image in the above xml code?
<action method="addLink" translate="label title" module="checkout">
<label>Cart</label>
<url helper="checkout/url/getCartUrl"/>
<title>Cart</title>
<prepare/>
<urlParams/>
<position>150</position>
<liParams />
<aParams><![CDATA[ class="cart"]]></aParams>
</action>
This should add a class cart to the <a> element. You can add your css on that class that hides the text and displays an icon.

Ribbon button should be hidden based on lead status - CRM 2011

I have custom button in lead ribbon. The custom button should be hidden when lead is qualified. How can I do that? Can any one please explain. I appreciate.
You can actually accomplish this entirely with built-in DisplayRule functionality. When a Lead is qualified, the StatusCode property is set to "Qualified", which translates into an OptionSet value of "3". You can check for the value of this property in a ValueRule and display/hide the control appropriately. I can think of two ways to achieve this:
Erik Pool's Visual Ribbon Editor
RibbonXml
<RibbonDiffXml>
<CustomActions>
<CustomAction Id="CompanyName.Form.lead.MainTab.Actions.Sample.CustomAction" Location="Mscrm.Form.lead.MainTab.Actions.Controls._children" Sequence="41">
<CommandUIDefinition>
<Button Id="CompanyName.Form.lead.MainTab.Actions.Sample" Command="CompanyName.Form.lead.MainTab.Actions.Sample.Command" Sequence="29" ToolTipTitle="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.LabelText" LabelText="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.LabelText" ToolTipDescription="$LocLabels:CompanyName.Form.lead.MainTab.Actions.Sample.Description" TemplateAlias="isv" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command">
<EnableRules />
<DisplayRules>
<DisplayRule Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command.DisplayRule.ValueRule" />
</DisplayRules>
<Actions>
<Url Address="http://www.bing.com" />
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="CompanyName.Form.lead.MainTab.Actions.Sample.Command.DisplayRule.ValueRule">
<ValueRule Field="statuscode" Value="3" />
</DisplayRule>
</DisplayRules>
<EnableRules />
</RuleDefinitions>
<LocLabels>
<LocLabel Id="CompanyName.Form.lead.MainTab.Actions.Sample.LabelText">
<Titles>
<Title languagecode="1033" description="Sample" />
</Titles>
</LocLabel>
<LocLabel Id="CompanyName.Form.lead.MainTab.Actions.Sample.Description">
<Titles>
<Title languagecode="1033" description="Sample Description" />
</Titles>
</LocLabel>
</LocLabels>
</RibbonDiffXml>

Resources