Filter out data in XPages view - xpages

There is a Notes view(view1).The each document in the view1 have information for ID and Name.
Then, there is another view(view2) in another DB.The each document in the view2 also have information for ID and Name.
As "XPages view", I'd like to display the documents in view1 which are filtered out by view2 data.
For example,
view1 in DB1 has 4 documents.
Doc1 - ID1, AAA
Doc2 - ID2, BBB
Doc3 - ID3, CCC
Doc4 - ID4, DDD
view2 in DB2 has 2 documents.
Doc1 - ID2, BBB
Doc2 - ID3, CCC
I'd like to see the data as a XPages view which filtered out by view2 data. Is this feasible?
Doc1 - ID1, AAA
Doc2 - ID4, DDD
I feel it is possible if I'd like to get the next data by 'filter by column value'option. But I'd like to get the opposite result in XPages view.
Doc1 - ID2, BBB
Doc2 - ID3, CCC

If you retrieve a DocumentCollection for each view, you can use the following set operations on those NotesCollections: Intersect, Subtract and Merge. I think you need Subtract in your case. These operations can be very slow, in my experience.
See, e.g.: https://www.ibm.com/support/knowledgecenter/en/SSVRGU_8.5.3/com.ibm.designer.domino.main.doc/H_SUBTRACT_METHOD_COLLECTION.html

You're not filtering out documents from view 2 in results from view 1. Because they're two different databases, they're not the same document. At the very least, the UNID and NoteID will be different and as these are properties of the document, they're different documents. They just have the same values for the subset of fields you've chosen to include in your question.
You will need to extract the ViewEntries into a List of Java objects using only the values you want, then filter accordingly.
The only alternative is to write an additional property to the documents in database 1 for IsInDatabaseTwo, which you can then filter on in your view's selection formula.

Related

Is there a vbo to get value from a collection based on value of other fields and save it as a data item?

Relatively new to Blue Prism,
I have a collection that looks like this, with 100+ rows:
Results
Answer
Timestamp
8 Apr 2021
Name
ABC
I'd like to manipulate the data such that if Results = 'Name', Get the Answer (aka ABC) and put it into a data item.
Is there any way to do this?
I understand I could hardcode i.e. Get value based on Row Index and Column Index, but my data is complex and may not always have the same rox index.
Can you use the collection filter to get a collection output? The utility has an action to filter where you can input a collection and then use
[FieldName] Like "some value"
This would result in every complete row in the collection that matches the filter.

How to add multiple items into a column SQLite3?

I don't want to use different python packages like pickle.
I also don't want to use multiple databases.
So, how do I add a list or a tuple into a column of a database?
I had a theory of adding a string that would be like '(val1, val2, val3)' and then use exec to put it into a variable but that is too far-fetched and there is definitely a better and more efficient way of doing this.
EDIT:
I'll add some more information on what I'm looking for.
I want to get (and add) lists with this type of info:
{'pet':'name','type':'breed/species_of_pet', 'img':img_url, 'hunger':'100'}
I want this dict to be in the pets column.
Each pet can have many owners (many-to-many relationship)
If you want to have a users table and each user can have pets. You'd first make a pets table.
create table pets (
id integer primary key,
name text not null,
hunger int not null default 0
);
Then it depends on whether a pet has only one owner (known as a one-to-many relationship) or many owners (known as a many-to-many relationship).
If a pet has one owner, then add a column with the user ID to the pets table. This is a foreign key.
create table pets (
id integer primary key,
-- When a user is deleted, their pet's user_id will be set to null.
user_id integer references users(id) on delete set null,
name text not null,
hunger int not null default 0
);
To get all the pets of one user...
select pets.*
from pets
where user_id = ?
To get the name of the owner of a pet we do a join matching each rows of pets with their owner's rows using pets.user_id and users.id.
select users.name
from users
join pets on pets.user_id = users.id
where pets.id = ?
If each pet can have many owners, a many-to-many relationship, we don't put the user_id into pets. Instead we need an extra table: a join table.
create table pet_owners (
-- When a user or pet is deleted, delete the rows relating them.
pet_id integer not null references pets(id) on delete cascade,
user_id integer not null references users(id) on delete cascade
);
We declare that a user owns a pet by inserting into this table.
-- Pet 5 is owned by users 23 and 42.
insert into pet_owners (pet_id, user_id) values (5, 23), (5, 42);
To find a user's pets and their name, we query pet_owners and join with pets to get the name.
select pets.*
from pet_owners
join pets on pet_owners.pet_id = pets.id
where user_id = ?
This might seem weird and awkward, and it is, but it's why SQL databases are so powerful and fast. It's done to avoid having to do any parsing or interpretation of what's in the database. This allows the database to efficiently query data using indexes rather than having to sift through all the data. This makes even very large databases efficient.
When you query select pets.* from pets where user_id = ?, because foreign keys are indexed, SQLite does not search the entire pets table. It uses the index on user_id to jump straight to the matching records. This means the database will perform the same with 10 or 10 million pets.
There is nothing stopping you from storing JSON or other array-like text in SQLite; it's just that it's much harder to query when you do so. SQLite does have facilities for manipulating JSON, but in general I would probably lean toward #Schwern's solution.

Sub entities in solr

I'm using solr to index an entity which has indefinite number of related entities
Table 1
id name
1 | aa
2 | bb
3 | cc
Table 2
id field1 field2
1 | works in | New York
1 | likes to go to | Paris
As you see, each row represents an entity related to entity with id 1 and which value corresponds which matters.
How do I achieve this with Solr's data import handler?
I used SubEntity in data-config.xml and multiValued=true for field1 and field2, but the indexed document looks like
id 1
field1:[works in, likes to go to]
field2:[New York, Paris]
and the relationships between columns were completely lost. If one searches works in Paris he can also get entity 1. What should I do to maintain the relationships? Thanks a lot.
Schema Definition in schema.xml
id(type string)
name(type string)
worksIn (type string, multi value= true) - your choice if multi-value required or not
likesToGo (type string, multi value= true) - multivalue makes sense here as person is,most likely have more places to go, anyways your requirement
Sample docs after indexing
1,aa, worksIn[Newyork, New Jeysey], likesToGo[Paris, Moon]
2,bb, worksIn[Dallas], likesToGo[NewYork, Sun]
Querying
For "works in Paris", query is "worksIn:Paris".
You get doc with id 1
For "likes to go to sun", query is "likesToGo:sun".
You get doc with id 2

Dynamics CRM 2011 creating relationships between custom entities

I have defined 3 entities in MSCRM 2011.
1-Place: This is the main entity. In this form I have some fields (let say IDs, Whole Number) that I want to create some relationships with other custom entities.
2-Category: This has two fields, ID(Whole number) and Category Name(text.) This is simply a relation entitiy.
3-Place-Category Relationship: This entity contains relationships between Category and Place. It has two main arguments, both of them are whole number.
One place can have more than one Category.
I want to display end user Place and the categories related to to that place entity.
Thanks in advance.
More info about this question:
- In Place entity each Place has a unique ID (1 = Train Station, 2 = Jhon's Kebab House, 3 = Nando's, 4 = Wagamama ...)
- In Place entity I have plenty of data but Category IDs are used to match places with categories (like 42, 108 etc.)
- In Category entity I have two fields. Category ID's matched with their category names (1 = Cafe, 2 = Restaurant ... 42 = Train Station, ... 108 = Grocery etc.)
- In Place-Category Relationship entity I have IDs of the places and the IDs for the cateories.(like PlaceID = 1 CategoryID =42, PlaceID = 2 CategoryID = 2, PlaceID = 2 CategoryID = 5 ..etc)
There are 140K Places, 200 Categories and more than 400K Place-Category Relationship.
One place has at least one, maximum 80 categories.
I want to match all my Places with their Categories entity (by aid of Place-Category Relationship entity).
I want to automate this matching process.
since you have said the each place can have many categories but not vice versa .
so you just need two entities (Place,category) and you should create a one to many
relationship between them.
open the default solution
Expand the place category
click on the 1:N relationship and create a relationship between it
and the category entity
Note: to open the "default solution" lick settings=> customizations => click customize the
system on the right

Complicated condition

I have predefined item combination (for example brand1|brand2|brand3 etc) in the table.
i like to collect brands and check against with predefined table data.
For example i collected brand1|brand2|brand3 then i can do get some value form that predefined table(it meets the condition).
How can i check?
brands would be unlimited. also brand1|brand2|brand3 of brand1|brand2| exist then returns true.
Okay, taking a wild guess at what you're asking, you have a delimited field with brands in them separated by a | character. You want to return any row that has the right combination of the brands in there, but don't want to return rows with, for example, brand "testify" in them when you search for "test".
You have four search conditions (looking for brand3):
the brand exists by itself: "brand3"
the brand starts the delimited field: "brand3|brand4|brand6"
the brand is in the middle of the field: "brand1|brand3|brand6"
the brand is at the end of the field: "brand1|brand2|brand3"
so, in SQL:
SELECT *
FROM MyTable
WHERE BrandField = 'brand3'
OR BrandField LIKE 'brand3|%'
OR BrandField LIKE '%|brand3|%'
OR BrandField LIKE '%|brand3'
Repeat as required for multiple brands.

Resources