Hi, I modified the poly module code for my notes functionality, specifically the case content demo.
I added a field to allow entry of note content to my note type, which was a case, but when I do a global update of the record, I get an error related to the linked primary object, the message is: org.apache.isis.core.metamodel.interactions.PropertyModifyContext cannot be cast to org.apache.isis.core.metamodel.interactions.ActionInvocationContext This is clearly a case of something that is contributed via an action being considered a property. In the original case demo there is an action for specifically updating the title, which still works for me. But its just the attempt to use the Edit button that causes an error. Do I need to add an Edit Content action as well? If so why, maybe I modified the contributions and broke something, or maybe adding contributions means this global update is not possible? The Primary contributions object is now as follows: /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package au.com.scds.chats.dom.module.note; import java.util.List; import javax.inject.Inject; import javax.jdo.annotations.NotPersistent; import org.apache.isis.applib.DomainObjectContainer; import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.Contributed; import org.apache.isis.applib.annotation.DomainService; import org.apache.isis.applib.annotation.NatureOfService; import org.apache.isis.applib.annotation.NotPersisted; import org.apache.isis.applib.annotation.Optionality; import org.apache.isis.applib.annotation.Parameter; import org.apache.isis.applib.annotation.SemanticsOf; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @DomainService( nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY ) public class NoteRelatedPrimaryContributions { //SC create a note and make object primary related @ActionLayout( contributed = Contributed.AS_ACTION ) public Note addNote(@Parameter(optionality=Optionality.MANDATORY) final String title, final NoteRelated noteRelatedPrimary) { Note aNote = notes.create(title); noteRelatedPrimaryLinks.createLink(aNote, noteRelatedPrimary); return aNote; } // //region > primary (contributed property) @Action( semantics = SemanticsOf.SAFE ) @ActionLayout( contributed = Contributed.AS_ASSOCIATION ) //@NotPersistent public NoteRelated primaryRelated(final Note aNote) { final NoteRelatedPrimaryLink relatedPrimaryLink = noteRelatedPrimaryLinks.findByNote(aNote); return relatedPrimaryLink != null? relatedPrimaryLink.getPolymorphicReference(): null; } //endregion //region > notes (derived collection) @Action( semantics = SemanticsOf.SAFE ) @ActionLayout( contributed = Contributed.AS_ASSOCIATION ) public List<Note> notes(final NoteRelated noteRelated) { final List<NoteRelatedPrimaryLink> links = noteRelatedPrimaryLinks.findByRelated(noteRelated); return Lists.newArrayList( Iterables.transform(links, NoteRelatedPrimaryLink.Functions.GET_CASE) ); } //endregion /**SC this is not needed as we set the primary as owner of a Note on creation //region > makePrimary (contributed action), resetPrimary (contributed action) @Action( semantics = SemanticsOf.IDEMPOTENT ) public Note makePrimary( final Note aNote, final NoteRelated noteRelated) { return setPrimary(aNote, noteRelated); } @Action( semantics = SemanticsOf.IDEMPOTENT ) public Note resetPrimary( final Note aNote) { return setPrimary(aNote, null); } private Note setPrimaryRelated(final Note aNote, final NoteRelated noteRelated) { final NoteRelatedPrimaryLink relatedLink = noteRelatedPrimaryLinks.findByNote(aNote); if(relatedLink != null) { container.removeIfNotAlready(relatedLink); } if(noteRelated != null) { noteRelatedPrimaryLinks.createLink(aNote, noteRelated); } return aNote; } public boolean hideMakePrimary(final Note aNote, final NoteRelated noteRelated) { // don't contribute to noteRelated return noteRelated != null; } public List<NoteRelated> choices1MakePrimary(final Note aNote) { return noteRelatedContributions.relateds(aNote); } //endregion */ @Inject private Notes notes; @Inject private NoteRelatedContributions noteRelatedContributions; @Inject private NoteRelatedPrimaryLinks noteRelatedPrimaryLinks; @Inject private DomainObjectContainer container; } Hoping there is a simple answer, this is almost done :) Cheers Steve
