In Camunda (7.12) I can query processes by variable value:
runtimeService.createProcessInstanceQuery()
.variableValueEquals("someVar", "someValue")
.list();
I can even query processes for null-value variables:
runtimeService.createProcessInstanceQuery()
.variableValueEquals("someVar", null)
.list();
But how can I query processes that do not have variable someVar?
I am not sure why you wouldn't have figured that out, but if i am correct what i think you are looking for , then looks like its pretty simple . The ProcessInstanceQuery class has also a method called variableValueNotEquals(String name, Object value) , that allows you select the processes that do not match a variable . In the Camunda Java API Docs it is stated as :
variableValueNotEquals(String name, Object value)
Only select process instances which have a global variable with the given name, but with a different value than the passed value.
Documentation page for your reference:
https://docs.camunda.org/javadoc/camunda-bpm-platform/7.12/?org/camunda/bpm/engine/RuntimeService.html
So i believe you can simply do :
runtimeService.createProcessInstanceQuery()
.variableValueNotEquals("someVar", null)
.list();
Let me know if that helps you .
First, get list of ids of all process instances which have "someVar"
Second, get list of all process ids in camunda
Get ids, from second list, which are not contained in first list.
Here is Kotlin sample as it's shorter than Java code, but concept is the same:
val idsOfProcessesWithVar = runtimeService.createVariableInstanceQuery().variableName("someVar").list().map {
it.processInstanceId
}
val allProcessesIds = runtimeService.createProcessInstanceQuery().list().map { it.id }
allProcessesIds.minus(idsOfProcessesWithVar)
Related
I am using data sources in Terraform to fetch a list of ids of my security groups as such:
data "aws_security_groups" "test" {
filter {
name = "group-name"
values = ["the-name"]
}
}
output "security_group_id" {
value = "The id is ${data.aws_security_groups.test.ids[*]}"
}
However, this is giving me the following error:
Error: Invalid template interpolation value
on main.tf line 11, in output "security_group_id":
11: value = "The id is ${data.aws_security_groups.test.ids[*]}"
|----------------
| data.aws_security_groups.test.ids is list of string with 1 element
Cannot include the given value in a string template: string required.
But if I use data.aws_security_groups.test.ids[0] instead it displays the ID.
Can someone help me to display the list of IDs?
First, I want to note that you don't necessarily need to combine this list with a string message at all if you don't want to, because Terraform will accept output values of any type:
output "security_group_ids" {
value = data.aws_security_groups.test.ids
}
If having them included as part of a bigger string is important for your underlying problem then you'll need to make a decision about how you want to present these multiple ids in your single string. There are various different ways you could do that, depending on what you intend to do with this information.
One relatively-straightforward answer would be to make the string include a JSON representation of the list using jsonencode, like this:
output "security_group_id_message" {
value = "The ids are ${jsonencode(data.aws_security_groups.test.ids)}"
}
If you want a more human-friendly presentation then you might prefer to use a multi-line string instead, in which case you can customize the output using string templates.
output "security_group_id_message" {
value = <<-EOT
The ids are:
%{ for id in data.aws_security_groups.test.ids ~}
- ${id}
%{ endfor ~}
EOT
}
Or, for an answer somewhere in between, you could use join to just concatenate the values together with a simple delimiter, like this:
output "security_group_id_message" {
value = "The ids are ${join(",", data.aws_security_groups.test.ids)}"
}
Note that I removed the [*] from your reference in all of these examples, since it isn't really doing anything here: data.aws_security_groups.test.ids is already an iterable collection, and so is compatible with all of the language features I used in the examples above.
IIRC the provider considers this ids attribute to be a set of strings rather than a list of strings, and so that [*] suffix could potentially be useful in other situations to force converting the set into a list if you need it to be typed that way, although if that is your intent then I'd suggest using one of the following instead so that it's clearer to a future reader what it does:
sort(data.aws_security_groups.test.ids) (if it being in lexical order is important to the behavior; Terraform uses lexical sorting by default anyway, but calling sort is a good prompt to a reader unfamiliar with Terraform to look up that function to see what the actual sort order is.)
tolist(data.aws_security_groups.test.ids) (functionally equivalent to sort above when it's a set of strings, but avoids the implication that the specific ordering is important, if all that matters is that it's a list regardless of the ordering)
I would like to select or filter scenarios by kinds in my Capella Project. When I use:
ownedScenarios.kind
It returns:
FUNCTIONAL
DATA_FLOW
FUNCTIONAL
DATA_FLOW
The first request I tried returns an empty set:
ownedScenarios->select(myScenario | myScenario.kind='DATA_FLOW')
The second one returns "ERROR: Couldn't find the 'filter(Set(EClassifier=Scenario),EClassifier=ScenarioKind)' service (78, 124)"
ownedScenarios->filter(interaction::ScenarioKind::DATA_FLOW)
Any idea why?
Thanks
interaction::ScenarioKind is an EEnum (an enumeration) and interaction::ScenarioKind::DATA_FLOW an EEnumLiteral (a value from the interaction::ScenarioKind enumeration) but the service filter() use an EClass as parameter. In order to filter on an EEnumLiteral you can use the select() service as in your first attempt:
ownedScenarios->select(myScenario | myScenario.kind = interaction::ScenarioKind::DATA_FLOW)
I have some data I need to process. It looks like a dictionary within a dictionary within a dictionary, all of which are being stored in a list! This is parsed JSON data so I have no control over the format of it.
Here is some of the data, I've deleted a lot of it as it's irrelevant and for brevity:
devices = [
{
'server.device.base.phyname': 'IEEE802.11',
'dot11.device': {
'dot11.device.associated_client_map': {
'68:96:1E:96:96:B5': '4202770DF206F63E_B5F4CE1EAB680000',
'60:30:CE:91:4A:96': '4202770DF206F63E_8D4A91D430600000',
'4C:32:75:66:96:10': '4202770DF206F63E_105F6675324C0000',
'50:6A:03:3E:0E:17': '4202770DF206F63E_170E3E036A500000',
'7C:C3:CE:A4:EC:86': '4202770DF206F63E_86ECA4A1C37C0000',
'2C:BE:08:F0:D5:A0': '4202770DF206F63E_A0D5F008BE2C0000',
'96:E7:96:76:9A:C7': '4202770DF206F63E_C79A762CE7700000',
'96:CE:75:57:E2:5A': '4202770DF206F63E_5AE2577510000000',
'34:68:95:96:3C:96': '4202770DF206F63E_C43C6A9568340000',
'6C:96:96:9D:CE:57': '4202770DF206F63E_57109DCF966C0000',
'CE:61:96:CE:B4:69': '4202770DF206F63E_69B4D2AE61900000',
'04:CE:CE:1C:CE:8C': '4202770DF206F63E_8CAF1CCE0C040000',
'2C:F0:CE:DC:D6:39': '4202770DF206F63E_39D6DCEEF02C0000'
}
}
}
]
I need to be able to extract the MAC addresses that are stored within the 'dot11.device' pair. I'm so far able to loop through the parent list and display all of the data:
for d in devices:
print d['dot11.device']['dot11.device.associated_client_map']
however this prints the whole nested dict.
What I'd really like to do is return a new list of just the MAC addresses (are they dictionary keys? I'm not sure).
I'm working with Python2 and any help is much appreciated!
Yes, they are indeed keys, and so the answer is quite simple:
for d in devices:
print d['dot11.device']['dot11.device.associated_client_map'].keys()
I am trying to write a xquery to get the Value for a specific name .Below is the request payload: i.e. if the Name ="ID" then get the
"Value" for that tag (i.e.1000000000.)If the Name="User" get the "Value" for that tag( ie."US").
<not:Items xmlns:v5="http://www.example.com"
xmlns:com="http://commom.com
xmlns:not="http://services.not.com"
xmlns:com1="http://common1.com">
<not:Array>
<com1:Item>
<v5:List>
<com:extensionsItem>
<com:Name>ID</com:Name>
<com:Value>1000000000</com:Value>
</com:extensionsItem>
<com:extensionsItem>
<com:Name>User</com:Name>
<com:Value>US</com:Value>
</com:extensionsItem>
</v5:List>
</com1:Item>
</not:Array>
</not:Items>
I tried the options below:
<ns2:ID>{fn:data($Items/not:Array/com1:Item/v5:List/com:extensionsItem[1]/com:Value)}<ID>
This statement works . But I cannot assure that ID will always come in first element in the array of List.So i want a statement that will work even if ID comes in any other
place in the array and I can retrieve the value.
Thanks in advance
I think you simply want to apply a predicate $Items/not:Array/com1:Item/v5:List/com:extensionsItem[com:Name = 'ID']/com:Value
I am trying to just do a basic INSERT operation to a PostgreSQL database through Python via the Psycopg2 module. I have read a great many of the questions already posted regarding this subject as well as the documentation but I seem to have done something uniquely wrong and none of the fixes seem to work for my code.
#API CALL + JSON decoding here
x = 0
for item in ulist:
idValue = list['members'][x]['name']
activeUsers.append(str(idValue))
x += 1
dbShell.executemany("""INSERT INTO slickusers (username) VALUES (%s)""", activeUsers
)
The loop creates a list of strings that looks like this when printed:
['b2ong', 'dune', 'drble', 'drars', 'feman', 'got', 'urbo']
I am just trying to have the code INSERT these strings as 1 row each into the table.
The error specified when running is:
TypeError: not all arguments converted during string formatting
I tried changing the INSERT to:
dbShell.executemany("INSERT INTO slackusers (username) VALUES (%s)", (activeUsers,) )
But that seems like it's merely treating the entire list as a single string as it yields:
psycopg2.DataError: value too long for type character varying(30)
What am I missing?
First in the code you pasted:
x = 0
for item in ulist:
idValue = list['members'][x]['name']
activeUsers.append(str(idValue))
x += 1
Is not the right way to accomplish what you are trying to do.
first list is a reserved word in python and you shouldn't use it as a variable name. I am assuming you meant ulist.
if you really need access to the index of an item in python you can use enumerate:
for x, item in enumerate(ulist):
but, the best way to do what you are trying to do is something like
for item in ulist: # or list['members'] Your example is kinda broken here
activeUsers.append(str(item['name']))
Your first try was:
['b2ong', 'dune', 'drble', 'drars', 'feman', 'got', 'urbo']
Your second attempt was:
(['b2ong', 'dune', 'drble', 'drars', 'feman', 'got', 'urbo'], )
What I think you want is:
[['b2ong'], ['dune'], ['drble'], ['drars'], ['feman'], ['got'], ['urbo']]
You could get this many ways:
dbShell.executemany("INSERT INTO slackusers (username) VALUES (%s)", [ [a] for a in activeUsers] )
or event better:
for item in ulist: # or list['members'] Your example is kinda broken here
activeUsers.append([str(item['name'])])
dbShell.executemany("""INSERT INTO slickusers (username) VALUES (%s)""", activeUsers)