Vaadin one to many Grid binding and expanding child entity - vaadin

There is the Customer entity which has a one to many relationship to entity Address,so there is a List<Address> getAddress in Customer.Entity Address has three columns,Street,City and Country.
So for instance to get the address details for one customer with two addresses you do
customer.getAddress.get(0).getStreet
customer.getAddress.get(0).getCity
customer.getAddress.get(0).getCountry
For the second address you do
customer.getAddress.get(1).getStreet
customer.getAddress.get(1).getCity
customer.getAddress.get(1).getCountry
Is there a way to display one row for the Customer details and display a sub-grid or (just dump the Address object's contents) that
expands the Address entity and shows the two address rows with the 3 columns?
In essence show the parent and expand the child.I was looking at TreeGrid but it requires a single type of bean like TreeGrid and I don't know how Address would fill into the picture.
Does the basic Grid have a feature like that? I see that you can add different types of columns with addComponentColumn,but is that only for UI elements,like adding buttons etc ?

you could use a LitRenderer for that, but displaying this much data in a grid would extend the height of a row a lot.
With addComponentColumn you can add any Component you want, like a single Button, Image or a more complex Layout that you created.
Like Tatu Lund suggested you can use the ItemDetailsRenderer. There you can implement a LitRenderer or a ComponentRenderer. Then you can display all complex information about the customer.

Related

How to model a "Character-Inventory-Item" schema in Core Data

Essentially I am trying to model a character holding a backpack with items from a pre-determined list. So far I have come up with this.
My main issue is in understanding how core data handles Arrays/Lists etc. From what I have read that is determined by the relationship, a simple character - item relationship is what I first came up with but I wanted to be able to add custom descriptions per item selected from the pre-determined items (which can be added to by the user at runtime). Each character would have only one "backpack" with a list of items with custom descriptions and custom "amounts" or count.
That backpack could theoretically have 2 of the same items but with different descriptions hence having a count of 2 for the one item wouldn't always be appropriate.
Also, there is the option for multiple character profiles, so therefore the items could belong to multiple different backpacks, but again with difference in description/count etc.
So I guess my main issue is understanding how Core Data handles lists. And how i could properly address this issue to allow for a "character-backpack-item" relationship.
Thanks!
Short and quick clean-up:
1: Add the properties from item to your BackPackItem
2: Remove the itementity
That backpack could theoretically have 2 of the same items but with
different descriptions
3: Add a property backpackItemID to your BackPackItem and assign a unique ID to it each time you create a BackPackItem entity. That way you can have multiple items with same information but with different ID's. (Not needed , but keeps things more clean in my opinion, do as you wish here)
Finally:
Now all you need to do when you fetch is to fetch the Character entity by it's name for example. And in your NSFetchRequest you add the BackPackItem (associatedBackPackItems as the relation is named) as relationshipKeyPathsForPrefetching, and all the associatedBackPackItems will be fetched for you automatically.
Now let's say you have fetched a Character , and you want to access its BackPackItem --> character.associatedBackpackItems gives you all the items connected to that character.

How to save multiple text inputs to Core Data with multiple rows in sections?

Okay so I'm making a app for fun to get a hang of things. This app is supposed to allow a user to input the number of times he or she has been paid from a client and which account/card number he or she used for the payment. The way I have this set up in CoreData is I have an entity for Client which contains:
details
name
entryId
sectionId
numberOfPayments
details is another cell type that I lets out in the picture that allows the user to input details about the client. I also have an entity for Payments that acts as a many to one relationship to Client that holds the amount and account number given that there can be many.
What I have trouble with is accessing the tableview to save all the data when the done button is hit. I was thinking about a nested for loop that would go through each section and for each row it will save the data accordingly like for Rob through an if statement it will know the first row is a part of the Client entity and every row after would be apart of the Payments entity as relationships. How would I access these individual cells? Is it possible to have this much flexibility with TableView or should I take a different approach.

MVC and Entity Framework - inserts, updates, best practice

I'll try to be short and clear with this question.
We have an asp.net mvc app that uses entity framework 4.
Our business model is relatively straightforward:
We have an object (which corresponds to a table) called Photo(s).
That photos table has a handful of columns that match up to properties on the object.
Description,Title,Date etc.
It also has a number columns that reference foreign keys for other tables:
AuthorId,LicenseId etc...
The author and license tables are complex in their own right, with multiple fields (Title,Summary,Date etc.)
I have multiple clients using this application to view their photos. I would like each client to dictate what fields they see when viewing the photos, as well as what fields they see when editing those fields.
My thought is to have tables setup saying client-a should see Field1,Field2 and Field3 when viewing their photos - and client-b should see Field1,Field4 and Field5. But some of these fields are not simply columns in the main photos table, they may be fields in a child table. so Field1 might be: Table.Photos.Title -> which corresponds to an object as: Objects.Photo.title...
but Field3 might be: Table.Licenses.LicenseSummary -> which corresponds to an object as: Objects.Photo.License.LicenseSummary
I'm trying to figure out the methodology that we would use to have a very data driven environment so in the DB I can say, display this object/property (for viewing or editing) and then it would know how to map to whatever table it needs to pull that information. also, during editing... give it some way to pull a list of available values if it is that type of property, and not just a text field.
I'm looking for an example of what this might involve, our model is actually more complex than this, but this is just an idea of what we are trying to accomplish. I don't know if what I'm trying to do is normal, perhaps it involves reflection? This is a new area for me.
If the clients are defining their own custom fields, I would simply give them a Key/Value pairs table.
PhotoID FK
Key string
Value string
Display bool
Note that this essentially amounts to EAV, which comes with its own set of difficulties.
If it's just about permissions on existing fields, you need to capture that information:
PhotoID FK
ClientID FK
FieldName string
Display Bool
You can use this information to inhibit the display of fields in the View. The easiest way to do that would be to use a loop in the View itself, writing the field to the output only if Display is set to true.

Grails how to set _idx field when INSERTing data from outside of the Grails application?

I have a scaffolded Grails application with two domains, Person and Course. Person belongs to Course, and Course hasMany Persons. I have modified show.gsp for Course to list all of the Persons associated with the selected Course.
To achieve this, Course.groovy contains the following line:
List persons = new ArrayList()
And, as a result, the "person" database table contains a persons_idx field. I frequently will be adding new data to the "person" table outside of my Grails application, from an external website.
When INSERTing new data, how to I figure out what to set persons_idx as?
I had originally used a SortedSet instead of an ArrayList for persons, since I care about sorting. But since I am sorting on Person.lastName, and there will always be multiple people with the same last name, then the list will exclude those persons who have the same last names as others. I wish there was another way...
Thanks.
Having two applications manipulate the same Database is a thing to avoid, when possible. Can your 2nd application instead call an action on the controlling app to add a Person to the Course with parameters passed to specify each? That way, only one app is writing to the DB, reducing caching, index, and sequence headaches.
You also state that Person belongsTo Course... so you create a new Person for "Bob Jenkins" for each course that he's in? This seems excessive. You should probably look into a ManyToMany for this.
Without moving to a service, unfortunately, you'd want to change the indices on some if not many of the rows for the children of the Course you're trying to add a Person to, as that index is the sorted index for all the Persons in the Course.
I would suggest going back to a "Set", and do your sorting in the app. Your other question about sorting already told you not to override compareTo to just check the last name. If I were you, I'd forget about overriding compareTo at all (except to check IDs, if you want), and just use the sort() method, passing in a closure that correctly sorts the objects.

Implement security for sharepoint lists

I have a share-point list with which I want to implement three things:
Freeze some columns so that their data can be edited by specific people only like the ones within site owners group with full privileges.
Hide some columns according to some user groups. Earlier I did this by creating two views, one with limited columns selected and visible to all and one with all columns with filter Restricted_user = [Me] and I have put all users' names from active directory in that field, but I guess it has security loopholes like someone could see all row data by selecting view item and everything in that row will be visible to him.
2.1. If my own second option approach is selected can I implement this comparison with group aliases, rather than individuals so that I have to put only group aliases in that column field, rather that all names in that group aliases.
Last but not the least can i break up list rows into two categories so that two different groups can access and edit their own data only.Eg. 20 rows are there 5 accessible to group1 and 15 accessible to group2 but they cant access each others data rows.
Apologies for long question.
The most secure way to accomplish #3 is using item level permissions. Less secure ways include custom views and audiences.
For #1 and #2, you will need to create custom field types. Out of the box SharePoint list columns do not support column based security.

Resources