Cocoa Scripting: "whose clause" cannot access certain properties - applescript

I am working on making my application scriptable. I struggle with the "whose" filter clause.
I want to make this work, but while name can be used, country can not:
tell application "myapp"
get every city whose name is "Berlin" -- works
get every city whose country is "Germany" -- error -1700 (Can’t make country into type specifier)
end tell
The relevant parts of the sdef look like this:
<class name="application" code="capp">
<cocoa class="NSApplication"/>
<element type="city">
<cocoa key="allCities"/>
<accessor style="index"/>
</element>
<class name="city" code="Citi" plural="cities">
<cocoa class="ScriptableCity"/>
<property name="name" code="pnam" type="text" access="r">
<cocoa key="name"/>
</property>
<property name="country" code="Ctry" type="text" access="r">
<cocoa key="country"/>
</property>
</class>
What must I do to make country work with "whose" as well? Apparently, the "whose" clause wants a type specifier, not a property name, but I can't make sense of this.
I have implemented indicesOfObjectsByEvaluatingObjectSpecifier:, but that only gets called for name, not for country.

Oh, I had it all wrong. My program code is fine. The issue is caused by the fact that I also have a class named country. So AppleScript, looking at the outmost scope for the identifier first, finds the class country and tries to use that for the comparison. Had the error message included the word "class", this would have been easier to detect, probably.
There are now two solutions:
Rename the property in the Sdef so that it does not clash with the class name any more, e.g. to country name.
Use of it in order to change the scope for the lookup of the identifier, like this:
get every city whose country of it is "Germany"
It is also important to make sure that if the same property name is used in several classes, they all use the same 4-char type code. Otherwise this problem can surface as well.

Related

XPath expression to pluck out attribute value

I have the following XML:
<envelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="vendor">
<fizz buzz="3"/>
</payload>
</envelope>
I am trying to write an XPath expression that will pluck out vendor (value for the payload's class attribute) or whatever its value is.
My best attempts are:
/dataEnvelope/payload[#class="vendor"]#class
But this requires the expression to already know that vendor is the value of the attribute. But if the XML is:
<dataEnvelope>
<action>INSERT</action>
<auditId>123</auditId>
<payload class="foobar">
<fizz buzz="3"/>
</payload>
</dataEnvelope>
Then I want the expression to pluck out the foobar. Any ideas where I'm going awry?
If you need #class value from payload node, you can use
/dataEnvelope/payload[#class]/#class
or just
/dataEnvelope/payload/#class
At first, your two XML files are out-of-sync - one references envelope and the other references dataEnvelope. So exchange one for the other, if necessary.
So, to get the attribute value of payload, you can use an XPath expression like this which uses a child's attribute value to be more specific:
/envelope/payload[fizz[#buzz='3']]/#class
Output is:
vendor
If the document element can/will change, then you can keep the XPath more generic and select the value of the class attribute from the payload element that is a child of any element:
/*/payload/#class
If you know that it will always be a child of envelope, then this would be more specific(but the above would still work):
/envelope/payload/#class

Is there a way to conditionally include attributes in custom JSP tag?

Lets say I have a field that can take 3 attributes
<myTag a="something" b="something" c="something" />
Let's say I want to only include those a,b,c attributes when a variables are not blank. So with EL it becomes something like this
<myTag a="${varA}" b="${varB}" c="${varC}" />
In the case that one or more of the variables are blank (say varB is empty) I'm getting output like:
<myTag a="a val" b c="c val" />
So b is still there, but passing a blank value.
This can cause problems with some spring <form:etc> tags if an attribute is blank (say itemLabel on form:options for example)
What if I don't want that? Is there an easy way to have the attribute not show up altogether?
I get that I can do
<c:if test="${empty b}">
<myTag a="${varA}" c="${varC}" />
</c:if>
But that means we need a giant decision tree as the number of attributes increase if each one can possibly be blank.
Does anyone know a better way to do this?

Redeem rate for Freestanding Coupons in Oracle ATG commerce

Any clue on how can I keep a track regarding how many Freestanding Coupons were used in Oracle ATG? I know that for bulk vouchers we have the Redemption Rate, but for the simple vouchers there's no such thing.
For example I created 500 vouchers with the code XXXXX and I want to see how many were used during the checkout.
Cheers
One way to do this would be to use the dyn/admin to query the number of uses for the given voucher code:
Open the ClaimableRepository in dyn/admin http://your-host-name:your-port/dyn/admin/nucleus/atg/commerce/claimable/ClaimableRepository/
In the text area below Run XML Operation Tags on the Repository enter the following:
<print-item item-descriptor="PromotionClaimable" id="my-promotion-id" /> and hit the 'enter' button. This will print something like this:
------ Printing item with id: my-promotion-id
<add-item item-descriptor="DeployablePromotionClaimable" id="my-promotion-id">
<set-property name="expirationDate"><![CDATA[11/26/2015 23:59:00]]></set-property>
<set-property name="displayName"><![CDATA[10% discount on my items]></set-property>
<!-- rdonly derived <set-property name="derivedDisplayName"><![CDATA[10% discount on my items]]></set-property> -->
<set-property name="uses"><![CDATA[4]]></set-property>
<!-- export is false <set-property name="version"><![CDATA[13]]></set-property> -->
<set-property name="lastModified"><![CDATA[10/28/2015 16:18:09]]></set-property>
<set-property name="status"><![CDATA[claimed]]></set-property>
<set-property name="startDate"><![CDATA[8/13/2015 00:00:00]]></set-property>
<!-- rdonly derived <set-property name="hasPromotions"><![CDATA[true]]></set-property> -->
<set-property name="promotions"><![CDATA[promo100001]]></set-property>
<set-property name="type"><![CDATA[DeployablePromotionClaimable]]></set-property>
</add-item>
The line <set-property name="uses"><![CDATA[4]]></set-property> tells you how many times that voucher/coupon has been used, which in this case is 4.
UPDATE:
The above method does not work as it returns the total number of coupons available when the promotion is setup. This means the quickest way to get this information would be to query the completed orders which use the coupon.

How to declaratively deploy a localized datetime field with validation?

The following column definition DOES work.
<Field ID="{F4313C31-C8DD-4917-98A9-0DE886177758}"
Type="DateTime"
Name="ExpirationDate"
DisplayName="Limited until (if necessary)"
StaticName="ExpirationDate"
Group="SomeGroup"
Required="FALSE"
Format="DateOnly"
FriendlyDisplayFormat="Disabled"
CalType="0">
<Validation Message="Please select a date in the future.">=[Limited until (if necessary)]>TODAY()</Validation>
But of course I do not want to use the display name in my validation formula.
Moving closer to production any display name will be moved a resx file anyway.
And using a resx file I end up with the same error as I encountered before when I was trying to use the internal field name instead of the display name.
The error is: The formula cannot refer to another column. Check the formula for spelling mistakes or update the formula to reference only this column.
This is what SharePoint does itself when creating a column via the UI:
<Field Type="DateTime" DisplayName="RS Expiration Date" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" FriendlyDisplayFormat="Disabled" ID="{15380d60-50d7-4ce1-b21b-92695f0c0811}" SourceID="{8086fd7d-ca0b-4258-9352-f166615b6159}" StaticName="RSExpDate" Name="RSExpDate" ColName="datetime2" RowOrdinal="0" CalType="0" Version="1">
<Validation Message="Please enter a future date." Script="function(x){return SP.Exp.Calc.valid(SP.Exp.Node.f('GT',[SP.Exp.Node.a(0),SP.Exp.Node.f('TODAY',[])]),x)}">=RSExpDate>TODAY()</Validation>
<ValidationDisplayNames>=[RS Expiration Date]>TODAY()</ValidationDisplayNames>
Obviously there's a lot of information in there you won't need.
The interesting part is the validation part. It is using "ValidationDisplayNames" instead of "Validation". Still the latter too does only work with display names.

How to use more than one custom filter invoked after each other?

hi all i am using spring security 3.0.2
and i have one custom filter and its order is last
and i want to add another filter after that filter, is the following config right ?
<custom-filter position="LAST" ref="filter1"/>
<custom-filter after="LAST" ref="filter2"/>
After looking in my own code I noticed that I didn't use the 'ref' attribute, but instead I place this tag inside my bean definition as follow:
<bean id="ntlmFilter" class="org.springframework.security.ntlm.samples.failover.NtlmProcessingFilter">
<sec:custom-filter position="NTLM_FILTER" />
<property name="authenticationManager" ref="authenticationManager" />
<property name="retryOnAuthFailure" value="false" />
<property name="securityConfiguration" ref="securityConfiguration" />
</bean>
Source: http://github.com/aloiscochard/spring-security-ntlm-samples/blob/master/spring-security-ntlm-samples-failover/src/main/resources/applicationContext-security.xml
Even if it's for spring-security 2, the behavior is the same in version 3.
You can find all possible position in the org.springframework.security.config.http.SecurityFilters enumeration:
http://grepcode.com/file/repo1.maven.org/maven2/org.springframework.security/spring-security-config/3.0.2.RELEASE/org/springframework/security/config/http/SecurityFilters.java
You can use some postition already defined in this enumeration to define in which order your custom filters must be set.
For exemple:
one filter before LAST and one at LAST (but not after LAST ! nothing can be after LAST !)
or one filter before SWITCH_USER_FILTER and one after.
Don't know where your are placing your tags ? but I like to have them directly inside the filter bean... easier to maintain :-)
Hope that's help !
PS: Since position are based on integer you can perhaps put number instead of enumeration value (be warn to us correct position number, look at the logic inside the SecurityFilters enumeration), not sure if accepted ...

Resources