// {{ ${actionName} (action)
${:import(org.apache.isis.applib.annotation.MemberOrder)}@MemberOrder(sequence="1")
public ${ReturnType} ${actionName}(final ${ParameterType} ${parameterType}) {
return ${cursor}null; // TODO: business logic here
}
// }}
${:import(java.util.Collections,java.util.List)}public List<${ParameterType}> choices${ParameterNumThenCapitalizedActionName}() {
return ${cursor}Collections.emptyList(); // TODO: return list of choices for argument N
}public ${ParameterType} default${ParameterNumThenCapitalizedActionName}() {
return ${cursor}null; // TODO: return default for argument N
}public String disable${ActionName}() {
return ${cursor}null; // TODO: return reason why action disabled, null if enabled
}public boolean hide${ActionName}() {
return ${cursor}false; // TODO: return true if action is hidden, false if visible
}public String validate${ActionName}(final ${ParameterType} ${parameterType}) {
return ${cursor}null; // TODO: return reason why action arguments are invalid, null if ok
}public void addTo${ChildCollectionName}(final ${ChildElementType} ${childElementName}) {
// check for no-op
if (${childElementName} == null ||
get${ChildCollectionName}().contains(${childElementName})) {
return;
}
// dissociate arg from its current parent (if any).
${childElementName}.clear${ParentPropertyNameInChild}();
// associate arg
${childElementName}.set${ParentPropertyNameInChild}(this);
get${ChildCollectionName}().add(${childElementName});
// additional business logic
onAddTo${ChildCollectionName}(${childElementName});
}
public void removeFrom${ChildCollectionName}(final ${ChildElementType} ${childElementName}) {
// check for no-op
if (${childElementName} == null ||
!get${ChildCollectionName}().contains(${childElementName})) {
return;
}
// dissociate arg
${childElementName}.set${ParentPropertyNameInChild}(null);
get${ChildCollectionName}().remove(${childElementName});
// additional business logic
onRemoveFrom${ChildCollectionName}(${childElementName});
}public void addTo${ParentCollectionName}(final ${ParentElementType} ${parentElementName}) {
// check for no-op
if (${parentElementName} == null ||
get${ParentCollectionName}().contains(${parentElementName})) {
return;
}
// delegate to parent to add
${parentElementName}.addTo${ChildCollectionNameInParent}(this);
// additional business logic
onAddTo${ParentCollectionName}(${parentElementName});
}
public void removeFrom${ParentCollectionName}(final ${ParentElementType} ${parentElementName}) {
// check for no-op
if (${parentElementName} == null ||
!get${ParentCollectionName}().contains(${parentElementName})) {
return;
}
// delegate to parent to remove
${parentElementName}.removeFrom${ChildCollectionNameInParent}(this);
// additional business logic
onRemoveFrom${ParentCollectionName}(${parentElementName});
}public void addTo${ChildCollectionName}(final ${ChildElementType} ${childElementName}) {
// check for no-op
if (${childElementName} == null ||
get${ChildCollectionName}().contains(${childElementName})) {
return;
}
// dissociate arg from its current parent (if any).
${childElementName}.removeFrom${ParentCollectionNameInChild}(this);
// associate arg
${childElementName}.get${ParentCollectionNameInChild}().add(this);
get${ChildCollectionName}().add(${childElementName});
// additional business logic
onAddTo${ChildCollectionName}(${childElementName});
}
public void removeFrom${ChildCollectionName}(final ${ChildElementType} ${childElementName}) {
// check for no-op
if (${childElementName} == null ||
!get${ChildCollectionName}().contains(${childElementName})) {
return;
}
// dissociate arg
${childElementName}.get${ParentCollectionNameInChild}().remove(this);
get${ChildCollectionName}().remove(${childElementName});
// additional business logic
onRemoveFrom${ChildCollectionName}(${childElementName});
}public String disable${CollectionName}() {
return ${cursor}null; // TODO: return reason why collection read-only, null if editable
}public boolean hide${CollectionName}() {
return ${cursor}false; // TODO: return true if hidden, false otherwise
}// {{ ${CollectionName} (Collection)
${:import(java.util.List,java.util.ArrayList,org.apache.isis.applib.annotation.MemberOrder)}private List<${ElementType}> ${collectionName} = new ArrayList<${ElementType}>();
@MemberOrder(sequence="1")
public List<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final List<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}
public void addTo${CollectionName}(final ${ElementType} ${elementName}) {
// check for no-op
if (${elementName} == null ||
get${CollectionName}().contains(${elementName})) {
return;
}
// associate new
get${CollectionName}().add(${elementName});
// additional business logic
onAddTo${CollectionName}(${elementName});
}
public void removeFrom${CollectionName}(final ${ElementType} ${elementName}) {
// check for no-op
if (${elementName} == null ||
!get${CollectionName}().contains(${elementName})) {
return;
}
// dissociate existing
get${CollectionName}().remove(${elementName});
// additional business logic
onRemoveFrom${CollectionName}(${elementName});
}
protected void onAddTo${CollectionName}(final ${ElementType} ${elementName}) {
}
protected void onRemoveFrom${CollectionName}(final ${ElementType} ${elementName}) {
}// {{ ${CollectionName} (Collection)
${:import(java.util.Set,java.util.LinkedHashSet,org.apache.isis.applib.annotation.MemberOrder)}private Set<${ElementType}> ${collectionName} = new LinkedHashSet<${ElementType}>();
@MemberOrder(sequence="1")
public Set<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final Set<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}
public String validateAddTo${CollectionName}(final ${ElementType} ${elementName}) {
return ${cursor}null; // TODO: return reason why argument cannot be added, null if ok to add
}
public String validateRemoveFrom${CollectionName}(final ${ElementType} ${elementName}) {
return null; // TODO: return reason why argument cannot be removed, null if ok to remove
}
// {{ injected dependencies
${cursor}
// }}
// {{ injected: ${ServiceType}
private ${ServiceType} ${serviceType};
public void set${ServiceType}(final ${ServiceType} ${serviceType}) {
this.${serviceType} = ${serviceType};
}
// }}
// {{ Create new (already persisted) ${Type}
public ${Type} new${Type}() {
${Type} ${type} = newTransientInstance(${Type}.class);
${cursor}// TODO: set up any properties
persist(${type});
return ${type};
}
// }}// {{ Create new (still transient) ${Type}
public ${Type} new${InstanceOfType}() {
${Type} ${type} = newTransientInstance(${Type}.class);
${cursor}// TODO: set up any properties
return ${type};
}
// }}// {{ Identification
${cursor}
// }}
public String iconName() {
return ${cursor}null; // TODO: return name of image file (without suffix)
}public String title() {
${:import(org.apache.isis.applib.util.TitleBuffer)}final TitleBuffer buf = new TitleBuffer();
${cursor}// TODO: append to TitleBuffer, typically value properties
return buf.toString();
}// {{ ${CollectionName} (Collection)
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Persistent)}@Persistent(mappedBy="${elementNameInChild}", dependentElement="${trueOrFalse}")
private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
@MemberOrder(sequence="1")
public SortedSet<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}// {{ ${CollectionName} (Collection)
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Persitent,javax.jdo.annotations.Join)}@Persistent(mappedBy="${elementNameInChild}", dependentElement="${trueOrFalse}")
@Join
private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
@MemberOrder(sequence="1")
public SortedSet<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}// {{ ${CollectionName} (Collection)
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Element)}
@Element(column="${ColumnName}", dependent="${trueOrFalse}")
private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
@MemberOrder(sequence="1")
public SortedSet<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}// {{ ${CollectionName} (Collection)
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Join,javax.jdo.annotations.Element)}@Join
@Element(dependent="${trueOrFalse}")
private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
@MemberOrder(sequence="1")
public SortedSet<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}// {{ ${CollectionName} (Collection)
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Persistent)}@Persistent(mappedBy="${ChildCollectionNameInParent}")
private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
public SortedSet<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}// {{ ${CollectionName} (Collection)
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Persistent,javax.jdo.annotations.Join,javax.jdo.annotations.Element)}@Persistent(table="${TableName}")
@Join(column="${ThisEntityFieldName}")
@Element(column="${RelatedEntityFieldName}")
private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();@MemberOrder(sequence="1")
public SortedSet<${ElementType}> get${CollectionName}() {
return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
this.${collectionName} = ${collectionName};
}
// }}// {{ ${PropertyName} (property)
private ${PropertyType} ${propertyName};
${:import(org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Column)}@MemberOrder(sequence="1")
@Column(allowsNull="${trueOrFalse}")
public ${PropertyType} get${PropertyName}() {
return ${propertyName};
}
public void set${PropertyName}(final ${PropertyType} ${propertyName}) {
this.${propertyName} = ${propertyName};
}
// }}
// {{ ${PropertyName} (property)
private ${PropertyType} ${propertyName};
${:import(org.apache.isis.applib.annotation.MemberOrder,javax.jdo.annotations.Column,javax.jdo.annotations.Persistent)}@MemberOrder(sequence="1")
@Column(allowsNull="${trueOrFalse}")
@Persistent(mappedBy="${fieldOnChild}")
public ${PropertyType} get${PropertyName}() {
return ${propertyName};
}
public void set${PropertyName}(final ${PropertyType} ${propertyName}) {
this.${propertyName} = ${propertyName};
}
// }}// {{ Lifecycle methods
${cursor}
// }}
public void created() {
${cursor}// TODO: post-create
}public void loading() {
${cursor}// TODO: pre-load
}
public void loaded() {
// TODO: post-load
}public void persisting() {
${cursor}// TODO: pre-persist
}
public void persisted() {
// TODO: post-persist
}public void removing() {
${cursor}// TODO: pre-remove
}
public void removed() {
// TODO: post-remove
}public void updating() {
${cursor}// TODO: pre-update
}
public void updated() {
// TODO: post-update
}// {{ ${PropertyName} (property)
private ${PropertyType} ${propertyName};
${:import(org.apache.isis.applib.annotation.MemberOrder)}@MemberOrder(sequence="1")
public ${PropertyType} get${PropertyName}() {
return ${propertyName};
}
public void set${PropertyName}(final ${PropertyType} ${propertyName}) {
this.${propertyName} = ${propertyName};
}
// }}
public void modify${ParentPropertyName}(final ${ParentPropertyType} ${parentPropertyName}) {
${ParentPropertyType} current${ParentPropertyName} = get${ParentPropertyName}();
// check for no-op
if (${parentPropertyName} == null ||
${parentPropertyName}.equals(current${ParentPropertyName})) {
return;
}
// delegate to parent to associate
${parentPropertyName}.modify${ChildPropertyNameInParent}(this);
// additional business logic
onModify${ParentPropertyName}(current${ParentPropertyName}, ${parentPropertyName});
}
public void clear${PropertyName}() {
${ParentPropertyType} current${ParentPropertyName} = get${ParentPropertyName}();
// check for no-op
if (current${ParentPropertyName} == null) {
return;
}
// delegate to parent to dissociate
current${ParentPropertyName}.clear${ChildPropertyNameInParent}();
// additional business logic
onClear${ParentPropertyName}(current${ParentPropertyName});
}public void modify${ChildPropertyName}(final ${ChildPropertyType} ${childPropertyName}) {
${ChildPropertyType} current${ChildPropertyName} = get${ChildPropertyName}();
// check for no-op
if (${childPropertyName} == null ||
${childPropertyName}.equals(current${ChildPropertyName})) {
return;
}
// dissociate existing
clear${ChildPropertyName}();
// associate new
${childPropertyName}.set${ParentPropertyNameInChild}(this);
set${ChildPropertyName}(${childPropertyName});
// additional business logic
onModify${ChildPropertyName}(current${ChildPropertyName}, ${childPropertyName});
}
public void clear${ChildPropertyName}() {
${ChildPropertyType} current${ChildPropertyName} = get${ChildPropertyName}();
// check for no-op
if (current${ChildPropertyName} == null) {
return;
}
// dissociate existing
current${ChildPropertyName}.set${ParentPropertyNameInChild}(null);
set${ChildPropertyName}(null);
// additional business logic
onClear${ChildPropertyName}(current${ChildPropertyName});
}public void modify${ParentPropertyName}(final ${ParentPropertyType} ${parentPropertyName}) {
${ParentPropertyType} current${ParentPropertyName} = get${ParentPropertyName}();
// check for no-op
if (${parentPropertyName} == null ||
${parentPropertyName}.equals(current${ParentPropertyName})) {
return;
}
// delegate to parent to associate
${parentPropertyName}.addTo${ChildCollectionNameInParent}(this);
// additional business logic
onModify${ParentPropertyName}(current${ParentPropertyName}, ${parentPropertyName});
}
public void clear${ParentPropertyName}() {
${ParentPropertyType} current${ParentPropertyName} = get${ParentPropertyName}();
// check for no-op
if (current${ParentPropertyName} == null) {
return;
}
// delegate to parent to dissociate
current${ParentPropertyName}.removeFrom${ChildCollectionNameInParent}(this);
// additional business logic
onClear${ParentPropertyName}(current${ParentPropertyName});
}${:import(java.util.List)}public List<${PropertyType}> choices${PropertyName}() {
return ${cursor}null; // TODO: return list of choices for property
}public ${PropertyType} default${PropertyName}() {
return ${cursor}null; // TODO: return default for property when first created
}public String disable${PropertyName}() {
return ${cursor}null; // TODO: return reason why property is disabled, null if editable
}public boolean hide${PropertyName}() {
return ${cursor}false; // TODO: return true if hidden, false if visible
}public void modify${PropertyName}(final ${PropertyType} ${propertyName}) {
${PropertyType} current${PropertyName} = get${PropertyName}();
// check for no-op
if (${propertyName} == null ||
${propertyName}.equals(current${PropertyName})) {
return;
}
// associate new
set${PropertyName}(${propertyName});
// additional business logic
onModify${PropertyName}(current${PropertyName}, ${propertyName});
}
public void clear${PropertyName}() {
${PropertyType} current${PropertyName} = get${PropertyName}();
// check for no-op
if (current${PropertyName} == null) {
return;
}
// dissociate existing
set${PropertyName}(null);
// additional business logic
onClear${PropertyName}(current${PropertyName});
}
protected void onModify${PropertyName}(final ${PropertyType} old${PropertyName}, final ${PropertyType} new${PropertyName}) {
}
protected void onClear${PropertyName}(final ${PropertyType} old${PropertyName}) {
}public String validate${PropertyName}(final ${PropertyType} ${propertyName}) {
if (${propertyName} == null) return null;
return ${cursor}null; // TODO: return reason why proposed value is invalid, null if valid
}// {{ ${SectionName}
${cursor}
// }}// {{ all ${TypePlural}
${:import(org.apache.isis.applib.annotation.Exploration,java.util.List)}@Exploration
public List<${Type}> all${TypePlural}() {
return allInstances(${Type}.class);
}
// }}
// {{ all ${TypePlural} that ${filterDescription}
${:import(org.apache.isis.applib.annotation.Exploration,org.apache.isis.applib.Filter,java.util.List)}@Exploration
public List<${Type}> all${TypePlural}Matching(final Filter<${Type}> filter) {
return allMatches(${Type}.class, filter);
}
// }}
// {{ first ${Type} that ${filterDescription}
${:import(org.apache.isis.applib.annotation.Exploration,org.apache.isis.applib.Filter,java.util.List)}@Exploration
public ${Type} first${Type}Matching(final Filter<${Type}> filter) {
return firstMatch(${Type}.class, filter);
}
// }}
// {{ unique ${Type} that ${filterDescription}
${:import(org.apache.isis.applib.annotation.Exploration,org.apache.isis.applib.Filter,java.util.List)}@Exploration
public ${Type} unique${Type}Matching(final Filter<${Type}> filter) {
return uniqueMatch(${Type}.class, filter);
}
// }}
public String validate() {
${cursor}// TODO: return reason why object is in invalid state (and so cannot be saved/updated), or null if ok
}