There are several functions in the R simmer package that have the argument id = 0. Usually the functions are associated with selecting a certain resource (e.g. seize_selected). I haven't been able to find any documentation on what this parameter does other than selection identifier for nested usage. Does anyone know what this means or have a use case for setting this to something other than its default value of 0?
I'm trying to see if it will help me select a coupled resource. For example, if I select "Bar1" resource, then I have to select "Server1" as a related resource. The wording of the reference makes me think this might help, but I'm not sure.
Yes, that's exactly what it is for. If you select a second resource, you lose your previous selection... unless you give it a different id. So, in your case:
... %>%
select("Bar1", id=0) %>%
...
select("Server1", id=1) %>%
...
and then you can use those ids in other activities to refer to those selections.
Related
I wanted to fetch the document which have the particular element attribute value.
So, I tried the cts:element-attribute-value-query but I didn't get any result. But the same element attribute value, I am able to get using cts:element-attribute-range-query.
Here the sample snippet used.
let $s-query := cts:element-attribute-range-query(xs:QName("tit:title"),xs:QName("name"),"=",
"SampleTitle",
("collation=http://marklogic.com/collation/codepoint"))
let $s-query := cts:element-attribute-value-query(xs:QName("tit:title"),xs:QName("name"),
"SampleTitle",
())
return cts:search(fn:doc(),($s-query))
The problem with range-query is it needs the range index. I have hundreds of DB's in multiple hosts. I need to create range indexes on each DB.
What could be the problem with attribute-value-query?
I found the issue with a couple of research.
Actually the result document is a french language document. It has the structure as follows. This is a sample.
<doc xml:lang="fr:CA" xmlns:tit="title">
<tit:title name="SampleTitle"/>
</doc>
The cts:element-attribute-value-query is a language dependent query. To get the french language results, then language needs to be mentioned in the option as follows.
cts:element-attribute-value-query(xs:QName("tit:title"),xs:QName("name"), "SampleTitle",("lang=fr"))
But cts:element-attribute-range-query don't require the language option.
Thanks for the effort.
I am trying to remove all users from a group using the Plone.Api method (within Plone4).
So I wrote this code:
users = api.user.get_users(groupname="The Test Group")
for user in users:
api.group.remove_user(groupname="The Test Group", username=user.id)
But the api.group.remove_user call does not seem to function. What is the proper way to remove users from a group within plone?
I paused this within my ipdb
This are the results from my calls:
ipdb> api.group.get(groupname=group_name)
<GroupData at /Plone/portal_groupdata/groupname:61fbc50d623142d7887384d70f25358b used for /Plone/acl_users/source_groups>
So far so good, I store this in a variable so I can try this again later (for the group argument).
ipdb> grp = api.group.get(groupname=group_name)
ipdb> api.user.get_users(groupname=group_name)
[<MemberData at /Plone/portal_memberdata/stolas#domain.org used for /Plone/acl_users>]
I notice I get my user from the group. Thus I am really in this group.
ipdb> user.id
'stolas#domain.org'
ipdb> api.group.remove_user(group=grp, username=user.id)
I try the remove call again, and check if my member is still within the group.
ipdb> api.user.get_users(groupname=group_name)
[<MemberData at /Plone/portal_memberdata/stolas#domain.org used for /Plone/acl_users>]
I still am..
Should I reindex security or something like that?
ps.
I also gave with api.env.adopt_roles(['Manager']) a try and the getToolByName(getSite(), 'portal_groups')
method portal_groups.removePrincipalFromGroup everthing rendered to a false.
plone.api uses the group tool to remove group memberships:
portal_groups = portal.get_tool('portal_groups')
portal_groups.removePrincipalFromGroup(user_id, group_id)
I guess your api.user.get_users(groupname="The Test Group") call returns an empty set.
Since you should pass the group name (group ID). Now you pass the group title.
The api.group.remove_user would also accept a group object instead of the group name.
Arguments ``groupname`` and ``group`` are mutually exclusive. You can
either set one or the other, but not both.
As I could not delete it as a user I thought of the following:
with api.env.adopt_roles(['Manager']):
api.user.delete(user=self.context)
parent = self.context.getParentNode()
parent.manage_delObjects([self.context.getId()])
As the user delete might fail I deleted the object as a Manager. This seemd to work without a Hitch.
I have a template which uses the same multivalued attribute in various places. I often find myself in a situation where I would like to filter the attribute before a template is applied to the individual values.
I can do this:
<#col:{c|<if(cond)><# c.Attribute2 #><endif>};separator=\",\"#>
but that is not what I want, because then there are separators in the output separating "skipped" entries, like:
2,4,,,6,,4,5,,
I can modify it to
<#col:{c|<if(c.Attribute1)><# c.Attribute2 #>,<endif>};separator=\"\"#>
Which is almost OK, but I get an additional separator after the last number, which sometimes does not matter (usually when the separator is whitespace), but sometimes does:
2,4,6,4,5,
I sometimes end up doing:
<#first(col):{c|<if(cond)><# c.Attribute2 #><endif>};separator=\"\"#>
<#rest(col):{c|<if(cond)>,<# c.Attribute2 #><endif>};separator=\"\"#>
But this approach fails if the first member does not satisfy the condition, then there is an extra separator in the beginning:
,2,4,6,4,5
Can someone give me a better solution?
First, let me point out that I think you are trying to do logic inside your template. Any time you hear things like "filter my list according to some condition based upon the data" it might be time to compute that filtered list in the model and then push it in. That said something like this might work where we filter the list first:
<col:{c | <if(c.cond)>c<endif>}:{c2 | <c2.c.attribute>}>
c2.c accesses the c parameter from the first application
The answer by "The ANTLR Guy" didn't help in my case and I found another workaround. See at Filter out empty strings in ST4
It is easy to calculate a sum, an average or a maximum accross set of fields using built-in xpath functions.
But is it possible to calculate a product?
Assuming I have repeating elements like
<my:table>
<my:row>
<my:value>10</my:value>
</my:row>
<my:row>
<my:value>20</my:value>
</my:row>
<my:row>
<my:value>30</my:value>
<my:row>
</my:table>
(the number of my:rows may vary).
i need to have a formula multiplying all my:values: 10*20*30 (and working with any number of rows).
Any ideas?
Please do not suggest code solutions, I need this for a restricted form.
Using conditional hack described here, I finally assembled the solution.
Inside my:row, create a running product field my:valueCumul, populated using a formula to refer to previous row, and leveraging the conditional hack to override NaN for the first row:
../my:value *
concat(
(count(../preceding-sibling::my:row[1]) = 0) * 1,
substring(../preceding-sibling::my:row[1]/my:valueCumul, 1, (count(../preceding-sibling::my:row[1]) = 1) * string-length(../preceding-sibling::my:row[1]/my:valueCumul))
)
Outside the table you can easily refer to my:valueCumul in the last row to get total product:
../my:row[count(../my:row)]/my:valueCumul
The nice features of this solution are:
Works in a browser form in any sharepoint environment
Is not impacted by "16 calculations" threshold
The formula is robust to row removal and shifts
You can't with the built in functions in InfoPath.
However, don't write off a code solution so fast. If you only access data elements in the form itself (nothing EXTERNAL) then you can leave the form as restricted security and the code will run with no problems - the user doesn't know the difference.
It is fairly trivial to attach to the right event, grab the nodes, and loop through them while multiplying. You don't even have to use managed code - use one of the script options. Comment back (or update your original post) if you run into any troubles and we can help resolve them.
I am using custom variables to track order ids. In order to aggregate analytics data into out data warehouse, I want to select a number of metrics with the custom variable as a dimension. However, if I do so, I will not get the entries where the variable is not set (E.g. sessions that didn't result in a sale). I need to get these as well.
Can I write a filter or segment that selects only the entries that doesn't have a particular custom variable? I have tried:
segment=dynamic::ga:customVarValue1==
But that doesn't seem to work (It gives no results back).
Basically I'm looking for the equivalent to where ga:customVarValue1 is null in sql.
In short, it's not possible to get the nullset data, as explained by a Google rep:
For some dimensions, GA uses the default value of (not set).
Custom Variable do not have a default value, so if a hit does not have a
custom variable associated with it, all the other dimensions in the query
are not added to the reports.
The original answer is a little confusing, but when you read between the lines it suggests that they throw out these "empty" values when they run their aggregates.
The "correct" approach, as he explains, is to set a default value for any row you want reported:
If you need to see the (not set) value, you could try sending a default
value for custom variables.
For example if you use visitor level custom vars to track member vs
non-member, you should always set non-member as a default for everybody;
then modify to member once they register.
Details are here: http://groups.google.com/group/google-analytics-data-export-api/browse_thread/thread/cd078ddb26ca18d5?pli=1
I've just had some success solving this by using a Regex to capture users or sessions where the custom dimension has no value. In my case I want to separate logged in and logged out users.
The Regex .+ will capture any non-empty value, so can be used to get the job done.
The filters for my Returning users segment is matches regex: .+ like this:
For the Customer prospects I used: does not match regex: .+ like this:
It's early days, but this appears to be working: