Hi,
After adding a few classes to my project, I am seeing 2 behaviors that make me wonder if I'm missing something or doing something wrong. I'm attaching 4 java files and 3 screenshots hoping to explain the situation clearly. The behavior appeared when I added two new classes, ANS and ITService (To keep this light I'm not including the superclass, which has common JDO parameters and some methods to control visibility). ITService contains an attribute of type ANS. When I create the ANS, the UI shows a button connected to the createITService action in ITServices. I think ANS is seeing that action as contributed since it has a parameter of type ANS, but that's something that hasn't happened with other classes. Is this how contributed actions are supposed to work? I managed to work around it using NatureOfService.VIEW_MENU_ONLY on the ITServices class, by the way. (screenshot1) I then create an ITService, and after the creation, the screen that shows the newly created object show the attribute of type ANS as null (screenshot2). However, if I click the edit button for that property, it shows a value, which makes me believe the "null" on the first screen is a glitch (screenshot3). If I use the list menu option and click on the IT Service again, the property shows a non null value. Thank you for setting up this mailing list, by the way. Cordial saludo, Hector Fabio Meza MartÃnez R&D Leader www.smartools.com.co [1] Links: ------ [1] http://www.smartools.com.co
/* * 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 domainapp.dom.smartae; import java.util.Date; import java.util.List; import javax.jdo.annotations.Column; import javax.jdo.annotations.VersionStrategy; import org.apache.commons.lang3.builder.CompareToBuilder; import org.apache.isis.applib.annotation.Auditing; import org.apache.isis.applib.annotation.BookmarkPolicy; import org.apache.isis.applib.annotation.DomainObject; import org.apache.isis.applib.annotation.DomainObjectLayout; import org.apache.isis.applib.annotation.ParameterLayout; import org.apache.isis.applib.annotation.Property; import org.apache.isis.applib.annotation.Where; import org.apache.isis.applib.services.i18n.TranslatableString; import domainapp.dom.smartae.elements.AEElement; @DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT, paged = 5, plural = "IT Services") @javax.jdo.annotations.PersistenceCapable() @javax.jdo.annotations.DatastoreIdentity(strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, column = "id") @javax.jdo.annotations.Version(strategy = VersionStrategy.DATE_TIME, column = "version") @javax.jdo.annotations.Queries({ @javax.jdo.annotations.Query(name = "find", language = "JDOQL", value = "SELECT " + "FROM domainapp.dom.smartae.ITService"), @javax.jdo.annotations.Query(name = "findByName", language = "JDOQL", value = "SELECT " + "WHERE name.indexOf(:name) >= 0 ") }) @DomainObject(auditing = Auditing.ENABLED, objectType = "IT Service") public class ITService extends AEElement implements Comparable<ITService> { @Column(allowsNull = "false") public String status; @Column(name="ANS_ID") ANS ans; public TranslatableString title() { return TranslatableString.tr("IT Service: {name}", "name", getName()); } @Override public int compareTo(ITService o) { CompareToBuilder compareToBuilder = new CompareToBuilder(); compareToBuilder.append(name, o.name); return compareToBuilder.toComparison(); } public ITService changeANS(@ParameterLayout(named = "change ANS") final ANS ans) { this.setAns(ans); return this; } public java.util.Collection<ANS> choices0ChangeANS() { List<ANS> ANSs = ansService.listAll(); ANSs.remove(getAns()); return ANSs; } @Override public String getDescription() { // TODO Auto-generated method stub return super.getDescription(); } @Override @Property(hidden=Where.ALL_TABLES) public String getRelease() { // TODO Auto-generated method stub return super.getRelease(); } @Override @Property(hidden=Where.ALL_TABLES) public Date getProductiveStart() { // TODO Auto-generated method stub return super.getProductiveStart(); } @Override @Property(hidden=Where.ALL_TABLES) public Date getProductiveEnd() { // TODO Auto-generated method stub return super.getProductiveEnd(); } @Override public String getName() { // TODO Auto-generated method stub return super.getName(); } @Override @Property(hidden=Where.ALL_TABLES) public Boolean getAvailableForInterfaces() { // TODO Auto-generated method stub return super.getAvailableForInterfaces(); } public String getStatus() { return status; } public void setStatus(String estado) { this.status = estado; } public ANS getAns() { return ans; } public void setAns(ANS ans) { this.ans = ans; } public boolean hideRelease () { return true; } public boolean hideAvailableForInterfaces () { return true; } public boolean hideProductiveEnd () { return true; } public boolean hideProductiveStart () { return true; } @javax.inject.Inject ANSs ansService; }
/* * 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 domainapp.dom.smartae; import java.util.List; import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.BookmarkPolicy; import org.apache.isis.applib.annotation.DomainService; import org.apache.isis.applib.annotation.DomainServiceLayout; import org.apache.isis.applib.annotation.MemberOrder; import org.apache.isis.applib.annotation.NatureOfService; import org.apache.isis.applib.annotation.Optionality; import org.apache.isis.applib.annotation.Parameter; import org.apache.isis.applib.annotation.ParameterLayout; import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.services.i18n.TranslatableString; import org.apache.isis.applib.services.repository.RepositoryService; @DomainService( nature = NatureOfService.VIEW, repositoryFor = ITServices.class ) @DomainServiceLayout( named="" + "Architecture Domains", menuBar = DomainServiceLayout.MenuBar.PRIMARY, menuOrder = "10.4" ) public class ITServices { //region > title public TranslatableString title() { return TranslatableString.tr("IT Services"); } //endregion //region > listAll (action) @Action( semantics = SemanticsOf.SAFE ) @ActionLayout( bookmarking = BookmarkPolicy.AS_ROOT, named="List IT Services" ) @MemberOrder(sequence = "1") public List<ITService> listAll() { return repositoryService.allInstances(ITService.class); } //endregion @ActionLayout( bookmarking = BookmarkPolicy.AS_ROOT, named="Create IT Services" ) @Action( semantics = SemanticsOf.SAFE ) @MemberOrder(sequence = "2") public ITService createITService( final @ParameterLayout(named="Name") String name, final @ParameterLayout(named="Description", multiLine=4) String description, final @ParameterLayout(named="Status") String status, final @ParameterLayout(named="ANS") @Parameter(optionality=Optionality.OPTIONAL) ANS ans ) { final ITService obj = repositoryService.instantiate(ITService.class); obj.setName(name); obj.setDescription(description); obj.setStatus(status); obj.setAns(ans); repositoryService.persist(obj); return obj; } public java.util.Collection<ANS> choices3CreateITService() { return repositoryService.allInstances(ANS.class); } //endregion //region > injected services @javax.inject.Inject RepositoryService repositoryService; @javax.inject.Inject public ANSs ansService; //endregion }
/* * 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 domainapp.dom.smartae; import java.util.Date; import java.util.SortedSet; import java.util.TreeSet; import javax.jdo.annotations.Column; import javax.jdo.annotations.Element; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.Inheritance; import javax.jdo.annotations.InheritanceStrategy; import javax.jdo.annotations.Join; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.VersionStrategy; import org.apache.commons.lang3.builder.CompareToBuilder; import org.apache.isis.applib.annotation.Auditing; import org.apache.isis.applib.annotation.BookmarkPolicy; import org.apache.isis.applib.annotation.Collection; import org.apache.isis.applib.annotation.DomainObject; import org.apache.isis.applib.annotation.DomainObjectLayout; import org.apache.isis.applib.annotation.MemberOrder; import org.apache.isis.applib.annotation.ParameterLayout; import org.apache.isis.applib.annotation.Property; import org.apache.isis.applib.annotation.PropertyLayout; import org.apache.isis.applib.annotation.Where; import org.apache.isis.applib.services.i18n.TranslatableString; import domainapp.dom.smartae.elements.AEElement; import domainapp.dom.smartae.elements.BusinessUnit; import domainapp.dom.smartae.elements.BusinessUnits; /*@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) @PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "smartAE", table = "ANS")*/ @PersistenceCapable() @DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT, paged = 5, plural = "ANS's") @javax.jdo.annotations.DatastoreIdentity(strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, column = "id") @javax.jdo.annotations.Version(strategy = VersionStrategy.DATE_TIME, column = "version") @javax.jdo.annotations.Queries({ @javax.jdo.annotations.Query(name = "find", language = "JDOQL", value = "SELECT " + "FROM domainapp.dom.smartae.ANS"), @javax.jdo.annotations.Query(name = "findByName", language = "JDOQL", value = "SELECT " + "WHERE name.indexOf(:name) >= 0 ") }) @DomainObject(auditing = Auditing.ENABLED, objectType = "ANS") public class ANS extends AEElement implements Comparable<ANS> { @Column(allowsNull = "true") @MemberOrder(name = "Object", sequence = "4") public String object; @Column(allowsNull = "true") @MemberOrder(name = "Observations", sequence = "6") @PropertyLayout(multiLine = 4) public String observations; @Column(allowsNull = "true") @MemberOrder(name = "Measure", sequence = "5") public Integer measure; @Persistent(table = "ANS_BUnit") @Join(column = "ANS_Id") @Element(column = "BUnit_id") @Collection() protected SortedSet<BusinessUnit> businessUnits = new TreeSet<BusinessUnit>(); public TranslatableString title() { return TranslatableString.tr("ANS: {name}", "name", getName()); } @Override public int compareTo(ANS o) { CompareToBuilder compareToBuilder = new CompareToBuilder(); compareToBuilder.append(name, o.name); return compareToBuilder.toComparison(); } @Override public String getDescription() { // TODO Auto-generated method stub return super.getDescription(); } @Override @Property(hidden=Where.ALL_TABLES) public String getRelease() { // TODO Auto-generated method stub return super.getRelease(); } @Override @Property(hidden=Where.ALL_TABLES) public Date getProductiveStart() { // TODO Auto-generated method stub return super.getProductiveStart(); } @Override @Property(hidden=Where.ALL_TABLES) public Date getProductiveEnd() { // TODO Auto-generated method stub return super.getProductiveEnd(); } @Override public String getName() { // TODO Auto-generated method stub return super.getName(); } @Override @Property(hidden=Where.ALL_TABLES) public Boolean getAvailableForInterfaces() { // TODO Auto-generated method stub return super.getAvailableForInterfaces(); } ///////////////////////////////////////////////////////////////////// @javax.inject.Inject BusinessUnits businessUnitService; public ANS add(@ParameterLayout(named = "Business Unit") final BusinessUnit tecComp) { // By wrapping the call, Isis will detect that the collection is // modified // and it will automatically send CollectionInteractionEvents to the // Event Bus. wrapperFactory.wrapSkipRules(this).addToBusinessUnits(tecComp); return this; } public String validateAdd(final BusinessUnit tecComp) { if (getBusinessUnits().contains(tecComp)) { return "Already a component"; } return null; } // provide a drop-down public java.util.Collection<BusinessUnit> choices0Add() { return businessUnitService.listAll(); } public ANS remove(@ParameterLayout(named = "Business Unit") final BusinessUnit tecComp) { // By wrapping the call, Isis will detect that the collection is // modified // and it will automatically send a CollectionInteractionEvent to the // Event Bus. // ToDoItemSubscriptions is a demo subscriber to this event wrapperFactory.wrapSkipRules(this).removeFromBusinessUnits(tecComp); return this; } // disable action dependent on state of object public String disableRemove(final BusinessUnit tecComp) { return getBusinessUnits().isEmpty() ? "No Business Units to remove" : null; } // validate the provided argument prior to invoking action public String validateRemove(final BusinessUnit tecComp) { if (!getBusinessUnits().contains(tecComp)) { return "Not a component"; } return null; } // provide a drop-down public java.util.Collection<BusinessUnit> choices0Remove() { return getBusinessUnits(); } public void addToBusinessUnits(final BusinessUnit tecComp) { getBusinessUnits().add(tecComp); } public void removeFromBusinessUnits(final BusinessUnit tecComp) { getBusinessUnits().remove(tecComp); } ////////////////////////////////////////////////////////// public String getObject() { return object; } public void setObject(String object) { this.object = object; } public String getObservations() { return observations; } public void setObservations(String observations) { this.observations = observations; } public Integer getMeasure() { return measure; } public void setMeasure(Integer measure) { this.measure = measure; } public SortedSet<BusinessUnit> getBusinessUnits() { return businessUnits; } public void setBusinessUnits(SortedSet<BusinessUnit> businessUnits) { this.businessUnits = businessUnits; } public boolean hideRelease () { return true; } public boolean hideAvailableForInterfaces () { return true; } public boolean hideProductiveEnd () { return true; } public boolean hideProductiveStart () { return true; } }
/* * 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 domainapp.dom.smartae; import java.util.List; import org.apache.isis.applib.Identifier; import org.apache.isis.applib.annotation.Action; import org.apache.isis.applib.annotation.ActionLayout; import org.apache.isis.applib.annotation.BookmarkPolicy; import org.apache.isis.applib.annotation.DomainService; import org.apache.isis.applib.annotation.DomainServiceLayout; import org.apache.isis.applib.annotation.MemberOrder; import org.apache.isis.applib.annotation.NatureOfService; import org.apache.isis.applib.annotation.Optionality; import org.apache.isis.applib.annotation.Parameter; import org.apache.isis.applib.annotation.ParameterLayout; import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.services.eventbus.ActionDomainEvent; import org.apache.isis.applib.services.i18n.TranslatableString; import org.apache.isis.applib.services.repository.RepositoryService; @DomainService( nature = NatureOfService.VIEW, repositoryFor = ANS.class ) @DomainServiceLayout( named="" + "Architecture Domains", menuBar = DomainServiceLayout.MenuBar.PRIMARY, menuOrder = "10.3" ) public class ANSs { //region > title public TranslatableString title() { return TranslatableString.tr("ANSs"); } //endregion //region > listAll (action) @Action( semantics = SemanticsOf.SAFE ) @ActionLayout( bookmarking = BookmarkPolicy.AS_ROOT, named="List ANSs" ) @MemberOrder(sequence = "1") public List<ANS> listAll() { return repositoryService.allInstances(ANS.class); } //endregion //region > create (action) public static class CreateDomainEvent extends ActionDomainEvent<ANSs> { public CreateDomainEvent(final ANSs source, final Identifier identifier, final Object... arguments) { super(source, identifier, arguments); } } @ActionLayout( bookmarking = BookmarkPolicy.AS_ROOT, named="Create ANS" ) @Action( domainEvent = CreateDomainEvent.class, semantics = SemanticsOf.SAFE ) @MemberOrder(sequence = "2") public ANS create( final @ParameterLayout(named="Name") String name, final @ParameterLayout(named="Description", multiLine=4) String description, final @ParameterLayout(named="Object") String object, final @ParameterLayout(named="Measure") int measure, final @ParameterLayout(named="Observations")@Parameter(optionality=Optionality.OPTIONAL) String observations) { final ANS obj = repositoryService.instantiate(ANS.class); obj.setName(name); obj.setDescription(description); obj.setObject(object); obj.setMeasure(measure); obj.setObservations(observations); repositoryService.persist(obj); return obj; } //endregion //region > injected services @javax.inject.Inject public RepositoryService repositoryService; @javax.inject.Inject public Attributes attributesService; //endregion }