Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
as discussed. 100% untested.
Comment | File | Size | Author |
---|---|---|---|
#20 | transitivity.patch | 3.96 KB | naught101 |
relation_reboot.patch | 7.13 KB | chx | |
Comments
Comment #1
chx CreditAttribution: chx commentedFun continues in the reboot branch.
Comment #2
naught101 CreditAttribution: naught101 commentedfor anyone else, ignore the patch, and just work off the "reboot" branch.
I added a clear button to the block, cause I didn't want to clear my session :). Should this block appear even when there are no entities loaded? Especially if there's already one entity picked?
Comment #3
naught101 CreditAttribution: naught101 commentedon chx's request, adding a settings page, but not properly. This is actually a per-relation-bundle settings page, and we really need to implement that first. The block would then need to be able to select which bundle, I suppose. It's at admin/structure/relation for now, as I imagine that will be the place for adding new bundles, and this can be moved to admin/structure/relation/[bundle]
Also, wtf is the 'creator' bundle for?
Comment #4
naught101 CreditAttribution: naught101 commentedHrm... in the proposal at http://groups.drupal.org/node/135804 we talk about keeping the dummy fields to define which bundles are available at the ends of the relation. We didn't discuss this heaps, and I think we need to, since all this settings crap is bundle-specific (I can't think of any relation settings that would be global - just as there aren't global node settings).
We don't really actually need the dummy fields, and I think it probably makes sense to have a bundle creation UI in the style of content types. I think the dummy fields would still be very valuable for formatters and widgets, and I think we could probably still use them in the way intended to create bundles (as a secondary UI), but all this could be done as a sub-module.
Comment #5
naught101 CreditAttribution: naught101 commentedEr... just realised that dummy fields cannot be the only core solution for determining which bundles are targetable by relations - if we did that, we wouldn't be able to reference non-fieldable entities, like files...
edit: And what about entities without bundles (again, files)
Comment #6
Shadlington CreditAttribution: Shadlington commentedI'm guessing the reboot branch isn't ready for non-developers to try out yet.
However, if you could post when you feel that feedback from non-developers would be useful then I (and no doubt, others) would love to help out by providing testing.
Comment #7
chx CreditAttribution: chx commentedOf course, will do. It's rather rough right now. You can try it, enable the block, go to a page where entities are loaded and you can create an entity. Even n-ary supports work (say octuplets form one relation), there is even some crude validation. n-ary relation loading, however, does not work yet so the relation entity page won't show all endpoints.
The config screen needs major love to add N endpoints of the relation instead of 1 (it's a meaningless mess right now). Also we need to store whether to load or not. Once we have endpoints stored we can have bundle validation. Heck, if entities are loaded on the page which have no applicable relations we can skip 'em from the UI.
The predicate input relation block likely can become a select box. Or not? How many predicates do we expect on a site? Anyways, I think ad-hoc predicate creation will be disallowed to protect from typos.
Finally we need to create an inline display mode and provide a default something. I guess links to the other endpoints? Or the relation entity page? Or both.
Comment #8
naught101 CreditAttribution: naught101 commentedSorry chx, I know you're champing at the bit, but I hate spending hours coding only to realise that it all has to be re-done (this is compounded by the fact that I'm a really slow coder).
Re: n-ary relations: I think there's two distinct cases here:
I cannot think of an example of why any n-ary directed relation could be better modelled by the n-ary octopus than the augmented relation model. If I'm right, and there is no such case (w3c doesn't mention one), then there is no reason to allow distinct sets of possible target bundles for the octopus relation type. For augmented relations, you are only ever talking about binary relations, and for those relations, we should supply "source" and "target" bundle sets.
For the bundle config page, were you thinking of changing the options available with javascript, depending on what options above were selected? Also, should we be giving relations a machine name?
Comment #9
naught101 CreditAttribution: naught101 commentedBTW, I added a list page, only list names, links to edit page. We can add more to this when we get to the field interface. Also changed the predicate in the block to an autocomplete. I don't think we should be creating relation types from here.
Comment #10
naught101 CreditAttribution: naught101 commentedterminology proposal:
arity: number of ends of the relation (eg. cardinality)
ary: index of the end of the relation
Comment #11
naught101 CreditAttribution: naught101 commentedchanged {relation_settings} to {relation_type}, to match node types. Changed "multi" to "arity", and added "label" and "directionality" columns. Methinks we will need two more boolean columns for directionality on the {relation_bundles} table (should this be {relation_type_bundles}? would make more sense to me), one for "source", one for "target".
chx: the relation/%relation page isn't working, and it makes absolutely no sense to me at the moment - you appear to be trying to get object properties of a scalar relation_id... I can't figure out where those properties are supposed to come from...
Comment #12
sunindex, please, just index. Self-descriptive FTW ;)
Comment #13
chx CreditAttribution: chx commentedWe have agreed on skipping directional octopuses for now. For now. Therefore octopuses do not have directions. We realized that if a relation has different bundle settings for each index then that, in itself specifies a direction and so undirected relations will have one bundle settings. Adding the two together, octopuses have one bundle setting, a minimum and maximum arity. Binary relations are either nondirectional which equals min 2 max 2 octopuses or directional and that's the only time we will provide different bundle settings.
Comment #14
naught101 CreditAttribution: naught101 commentedsun: index is an SQL reserved word. I used r_index.
Big reshuffle of schema.
Settings page is now working, and submitting fine, using states. Perhaps we should change predicate->type, and label->name, like node?
Now on to validation for relation creation, and viewing relations...
Comment #15
naught101 CreditAttribution: naught101 commentedValidation is about half way there. Creating directional relations is going to be difficult.
added proper entity info.
I'm having trouble figuring out how to deal with n-ary relations. currently the loaded entity data looks like this:
that should be replaced with :
Not sure if this should be in the buildQuery, or if I should move it. Problem is that the bundle (which contains the arity, which is needed to create the $query) is apparently not available ($ids doesn't seem to contain it, though it looks like it should).
catch suggested it might be better to load the relation_data rows in EntityController::attachLoad, but I don't have any experience with this stuff, so I thought I'd ask first.
Comment #16
chx CreditAttribution: chx commentedI was trying to avoid two queries -- one for relation, one for relation_data -- with storing "is this an octopus?" in a variable. I agree that octopus needs separate queries and attachLoad might be a good place for that.
Comment #17
jdelaune CreditAttribution: jdelaune commentedSo I'm trying to test this module out and provide some feedback. I've checked out the reboot branch from GIT and I've setup a 'relation' under site structure. But I can't seem to be able to add any kind of 'relation field' to my entities and thus test out the new 'browser'.
Is this not how relation works any more?
Comment #18
naught101 CreditAttribution: naught101 commentedjdelaune: Correct. You need to go to admin/structure/blocks, and enable the relation block. Then you need to go to admin/structure/relation and create one or more relation types.
Next you need to go to any page that displays one or more entities of any type, and the block will show up. use the autocomplete to select your relation type (yes, we know this needs some work), and "pick" at least two entities, then press "create relation". You'll see a message that links to the entity viewer page, which isn't complete yet.
At the moment, n-ary entity loading is not working, so the entity display page only shows two entities, and no other information. We know there are a lot of bugs and features missing, that's because we've been focussing on the back end first - have a look at the hook_schema implementation in the .install file to see the layout. Basically, the tables are:
"relation_type" - same idea as node_type, stores relation bundles
"relation bundles" - stores the bundles that are available to each relation type (validation not implemented yet).
"relation" - stores the basic information on each relation entity.
"relation_data" stores the "arms" of the relation - ie. the data on which entities are part of the relation. There are at least two rows for every relation.
Comment #19
naught101 CreditAttribution: naught101 commentedentity loading complete. I moved it to attachLoad because the buildQuery had no way of separating different rows into differently named fields - ie. load 3 rows, and the second row overwrites the first, and the 3rd overwrites the second. Anyway, it works now. relation entity page also works now.
Comment #20
naught101 CreditAttribution: naught101 commentedPatch for transitivity, also removes a few notices.
Comment #21
naught101 CreditAttribution: naught101 commentedComing along. A few more tests to add..
There's a minor validation problem, see:
git show 2ec0ca5
If we don't validate in relation_create, then there's no validation for programatically created fields. If we do, then we're validating twice. I guess we could have a 'validated' flag already, but I don't really know what the best solution is for this one..
Comment #22
BenK CreditAttribution: BenK commentedGreat work coming along here... subscribing.
Comment #23
naught101 CreditAttribution: naught101 commentedFor anyone else, if you're not here to test and comment/provide patches, please subscribe to #1059018: Initial release? (Relation) instead of here, so we can keep this issue relatively clean. I will add notices there when significant progress is made (eg. alpha/beta/final releases).
Comment #24
naught101 CreditAttribution: naught101 commentedrelation_dummy_field. Oooh yeeaah!
No field data required >:)
Comment #25
jdelaune CreditAttribution: jdelaune commentedNice I'll check it out later. I tried it the other day but it didn't make much sense making the relations from a block. Hopefully making them from within a field will make the process more intuitive.
But I know you've been concentrating on the foundations which look great.
Comment #26
naught101 CreditAttribution: naught101 commentedThe field does not create relations, just displays them. Field-based relation creation may come later, but will be difficult. It definitely won't be part of the first alpha.
Comment #27
jdelaune CreditAttribution: jdelaune commentedAh okay, is there a reason you choose to create relations through a block rather than just an admin screen?
Comment #28
naught101 CreditAttribution: naught101 commentedjdelaune: the basic concept is "you load it, we relate it" - it's very difficult to find entites of all types using an auto complete, for example, so we just use hook_entity_load to gather info on all entities loaded on the page, and then list those as options for relation end points. Other UIs will be possible, we'll see what we come up with (or what others come up with)
for details, see http://groups.drupal.org/node/135804
Comment #29
naught101 CreditAttribution: naught101 commentedThis has been merged into the 7.x-1.x branch. Feel free to post any bugs on the issue queue.
Comment #31
steveoliver CreditAttribution: steveoliver commentedRe: #28, creating relations: see Relation Select -- a field widget for creating & editing relations.